Computer Science EngineeringHard

Quicksort that always picks the first element as pivot runs in what time on an already sorted array?

  1. A. O(n log n)
  2. B. O(n)
  3. C. O(n^2)
  4. D. O(log n)

Correct answer: C. O(n^2)

Each partition splits into sizes 0 and n-1, giving n + (n-1) + ... = O(n^2).

More Algorithms, Data Structures & Programming (ISRO CS) questions

Exams that ask this topic