Algorithms and Data Structures · Senior · Question 68 of 75

What does randomization give quicksort?

Explanation

With a random pivot no fixed input is consistently bad, so the expectation holds for any input, including adversarial ones. The worst case is still possible, just extremely unlikely.

Further reading

Problem with a question

Algorithms and Data Structures · Senior · question 68

Test yourself

Take the Algorithms and Data Structures · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz