+1 vote
in Data Structures & Algorithms II by (110k points)
The given array is arr = {3,4,5,2,1}. The number of iterations in bubble sort and selection sort respectively are __________

(a) 5 and 4

(b) 4 and 5

(c) 2 and 4

(d) 2 and 5

This question was posed to me at a job interview.

Origin of the question is Selection Sort in chapter Sorting of Data Structures & Algorithms II

1 Answer

+1 vote
by (614k points)
selected by
 
Best answer
Right option is (a) 5 and 4

Best explanation: Since the input array is not sorted, bubble sort takes 5 iterations and selection sort takes 4(n-1) iterations.

Related questions

Welcome to TalkJarvis QnA, a question-answer community website for the people by the people. On TalkJarvis QnA you can ask your doubts, curiosity, questions and whatever going in your mind either related to studies or others. Experts and people from different fields will answer.

Categories

...