1.

Which is the safest method to choose a pivot element?(a) choosing a random element as pivot(b) choosing the first element as pivot(c) choosing the last element as pivot(d) median-of-three partitioning methodI got this question in an internship interview.Question is taken from Quicksort topic in section Sorting of Data Structures & Algorithms II

Answer»

Right choice is (a) choosing a random ELEMENT as pivot

For explanation: This is the SAFEST method to choose the pivot element since it is very unlikely that a random pivot would CONSISTENTLY provide a poor PARTITION.



Discussion

No Comment Found

Related InterviewSolutions