+1 vote
in Data Structures & Algorithms II by (110k points)
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 method

I got this question in an internship interview.

Question is taken from Quicksort topic in section Sorting of Data Structures & Algorithms II

1 Answer

+1 vote
by (614k points)
selected by
 
Best 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.

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

...