Math, asked by srai5237, 19 days ago

Show that the second smallest of n elements can be found with comparisons in the worst case. (hint: also find the smallest element.)

Answers

Answered by shreyao45678
0

Answer:

compare the first two numbers, assign the lower number min and the bigger one to next_min

compare the first two numbers, assign the lower number min and the bigger one to next_minloop through numbers 3 - n, if the number is lower than min, set min to that number. else if the number if lower than next_min set next_min to that number

compare the first two numbers, assign the lower number min and the bigger one to next_minloop through numbers 3 - n, if the number is lower than min, set min to that number. else if the number if lower than next_min set next_min to that numberIf this is the optimal solution how can I prove the number of comparisons is n + lg n - 2.

Step-by-step explanation:

hope it helps.....

Answered by saheerbapputty1
0

The second smallest of n elements can be found with _______ comparisons in worst case. 1 is the smallest, it took n-1 = 7 comparisons. Now compare all the numbers which 1 was compared to (compare 2,3,5). 2 is the second smallest.

make my answer as brainlist

Similar questions