🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Merge Sort and Quick Sort: all 13 questions

Quiz: Merge Sort and Quick Sort · Question 3 of 13

When does quick sort with "last element as pivot" take O(n²)?

When does quick sort with "last element as pivot" take O(n²)?

  1. A.When the array has only distinct values
  2. B.When the array is already sorted
  3. C.When the array has an even length
  4. D.Never
Answer & explanation

Correct answer: When the array is already sorted

On sorted input the last element is the largest, so each partition removes just one item.

Can you get the rest right without peeking?

Take the timed Quiz: Merge Sort and Quick Sort quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →