1.

Consider the Quick sort algorithm in which the partitioning procedure splits elements into two sub-arrays and each sub-array contains at least one-fourth of the elements. Let T(n) be the number of comparisons required to sort array of n elements. Then T(n)

Answer»

Right option is (B) T(n) <= T(n/4) + T(3n/4) + cn

The explanation is: If there are n/4 ELEMENTS in one sub-array then T(n/4) comparisons are needed for this sub-array. And T(3n/4) COMPARISON are required for the rest 4n/5 elements, and cn is TIME required for finding the pivot. If there are more than n/4 elements in one sub-array then other sub-array will have less than 3n/4 elements and time complexity will be less than T(n/4) + T(3n/4) + cn.



Discussion

No Comment Found

Related InterviewSolutions