1.

The given array is arr={7,4,5,8,1,2}. The number of iterations required to sort the array using comb sort and bubble sort respectively will be _______(a) 7 and 8(b) 5 and 6(c) 5 and 5(d) 4 and 5I got this question in an interview for internship.The above asked question is from Sorting in portion Sorting of Data Structures & Algorithms II

Answer»

The correct answer is (d) 4 and 5

Best explanation: Comb sort takes 1 iteration LESS as compared to BUBBLE sort as it makes USE of variable GAP value WHEREAS bubble sort uses a constant gap value of 1.



Discussion

No Comment Found

Related InterviewSolutions