1.

The worst case occurs in quick sort when _________(a) Pivot is the median of the array(b) Pivot is the smallest element(c) Pivot is the middle element(d) None of the mentionedThe question was asked in class test.My question is taken from Algorithms topic in division Algorithms of Discrete Mathematics

Answer»

Right ANSWER is (B) PIVOT is the smallest ELEMENT

To ELABORATE: This happens when the pivot is the smallest (or the largest) element. Then one of the partitions is empty, and we repeat recursively the procedure for N-1 elements.



Discussion

No Comment Found

Related InterviewSolutions