Data Structures & AlgorithmsHardGATE CS · TCS NQT · Product Company SDE

Quicksort uses the Lomuto partition with the last element as pivot on [32, 15, 43, 18, 25, 39, 6]. After one partition call, at which index (0-based) does the pivot end up?

  1. A. -2
  2. B. -1
  3. C. 0
  4. D. 1

Correct answer: C. 0

The pivot 6 ends at index = count of elements ≤ 6 before it = 0. Array after partition: [6, 15, 43, 18, 25, 39, 32].

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

Exams that ask this topic