The GATE Grind

GATE 2024 DA – Question 30

Programming, Data Structures and Algorithms · Divide and conquer: mergesort and quicksort · 1 mark · Numerical answer

Consider sorting the following array of integers in ascending order using an in-place Quicksort algorithm that uses the last element as the pivot.

60708090100

The minimum number of swaps performed during this Quicksort is ______.

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: 0

Explanation

The array is already sorted. With the last element as the pivot, every other element is smaller than the pivot and already in place, so partitioning does not need to move any element, and the same holds for each sub-array that follows. The minimum number of swaps is 0.