Question
In a Selection Sort algorithm, the inner loop finds the
index of the minimum element in the unsorted part. Which line correctly completes the if condition to update min_idx? def selection_sort(arr):   n = len(arr)   for i in range(n - 1):     min_idx = i     for j in range(i + 1, n):       if __________: # Line to complete         min_idx = j     arr[i], arr[min_idx] = arr[min_idx], arr[i]Solution
Correct Answer: A • Code Analysis: o min_idx initially holds the index of the current assumed minimum (which is i). o The inner loop (for j in range(i + 1, n)) iterates through the rest of the unsorted array. o The if condition needs to check if the element at the current index j is smaller than the element currently considered the minimum (at min_idx). If it is, then j becomes the new min_idx. • Explanation of Correct Answer (A): arr[j] < arr[min_idx] o This condition directly compares the value at the current index j with the value at the min_idx found so far. If arr[j] is indeed smaller, it means we've found a new minimum, and min_idx should be updated to j. This is the core logic for finding the minimum element.
On which date, the International Day for the Abolition of Slavery is observed?
What is the additional capital requirement for SBI as per its D-SIB classification? Â
Which of the following places in India is famous for mangrove vegetation?
Which Hollywood actor and producer will be honored with the prestigious Satyajit Ray Lifetime Achievement Award at the 54th International Film Festival ...
Who won the Orange Cap for scoring the most runs in IPL 2024?
Kajari festival which begins on the day of the shukla navami is related to the farmers and celebrated in the state of ______ at the beginning of the sow...
Which of the following is not a feature of capitalist economy?
Consider the following countries:
1.Azerbaijan
2.Turkmenistan
3.Armenia
4.China
5.India
6.Iran
7.Kyrgyz...
Which organization recently put up a signboard in the village of Mana, in the state of Uttarakhand, India, near the India-China border?
The purple frog, also known as pignose frog is endemic to which part of India?