GATE DA 2024 Q30: Swaps by Quicksort with last-element pivot on a sorted array
- Programming, Data Structures and Algorithms
- 1 mark
- NAT
- No negative marking
Question
Consider sorting the following array of integers in ascending order using an in-place Quicksort algorithm that uses the last element as the pivot.
60 70 80 90 100
The minimum number of swaps performed during this Quicksort is ______.
Try it: numerical answer: type the value
Show answer and explanation
Answer: 0 (official GATE 2024 final answer key)
Concept used: Quicksort partitioning only needs to swap elements that are on the wrong side of the pivot.
First step: In a sorted array every element is already on the correct side of each pivot, so no exchange of distinct positions is needed.
Full step-by-step solution
Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.
Share this question
Source: official GATE 2024 DA question paper and final answer key, organised by IISc Bangalore. Question paper · Answer key
More Programming, Data Structures and Algorithms PYQs
- 2026 · Q15Expected-time recurrence for randomised-input quicksort
- 2026 · Q16Python mutable default argument output
- 2026 · Q25Binary tree from preorder and inorder traversals
- 2026 · Q31Worst-case comparisons in binary search of 1000 elements
- 2026 · Q39Number of calls made by a Fibonacci-like recursion
- 2026 · Q40Reachability in a graph and its reverse