+1 vote
in Data Structures & Algorithms II by (110k points)
Which is the worst method of choosing a pivot element?

(a) first element as pivot

(b) last element as pivot

(c) median-of-three partitioning

(d) random element as pivot

I got this question by my school principal while I was bunking the class.

My doubt stems from Quicksort in chapter Sorting of Data Structures & Algorithms II

1 Answer

+1 vote
by (614k points)
selected by
 
Best answer
Right answer is (a) first element as pivot

The best I can explain: Choosing the first element as pivot is the worst method because if the input is pre-sorted or in reverse order, then the pivot provides 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

...