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

Quicksort uses the Lomuto partition with the last element as pivot on [42, 63, 77, 95, 70, 32, 1, 32, 76]. After one partition call, at which index (0-based) does the pivot end up?

  1. A. 7
  2. B. 5
  3. C. 6
  4. D. 8

Correct answer: C. 6

The pivot 76 ends at index = count of elements <= 76 before it = 6. Array after partition: [42, 63, 70, 32, 1, 32, 76, 95, 77].

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

Exams that ask this topic