Data Structures & AlgorithmsModerateTCS NQT · Infosys pattern

Quick sort with the Lomuto partition (pivot = last element) is run on an already sorted array of 10 distinct elements. How many element-to-pivot comparisons does it make?

  1. A. 10
  2. B. 45
  3. C. 34
  4. D. 90

Correct answer: B. 45

The pivot is always the largest element, so each partition removes just one element: 9 + 8 + … + 1 = 10 × 9/2 = 45 comparisons, the O(n²) worst case. About 34 would be n log₂ n for balanced splits.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic