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

Quicksort uses the Lomuto partition with the last element as pivot on [99, 24, 44, 86, 76, 60, 84, 3]. After one partition call, at which index (0-based) does the pivot end up?

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

Correct answer: A. 0

The pivot 3 ends at index = count of elements <= 3 before it = 0. Array after partition: [3, 24, 44, 86, 76, 60, 84, 99].

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

Exams that ask this topic