Consider sorting the following array of integers in ascending order using an…

2024

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

image.png

The minimum number of swaps performed during this Quicksort is ____

Attempted by 146 students.

Show answer & explanation

Correct answer: 0

The array is:
[60, 70, 80, 90, 100]

  • It is already sorted in ascending order.

  • Quicksort uses the last element (100) as pivot.

  • During partitioning, every element is already on the correct side of the pivot.

  • No actual data movement is required.

If we count only real swaps (excluding self-swaps), the minimum number of swaps performed is:0

Explore the full course: Gate Guidance By Sanchit Sir