ITPEC FE Morning October 2020 Question 7

Which of the following is a description of quicksort algorithm?

Explanation

Pick a pivot, then partition smaller elements before it and larger ones after — quicksort repeats this on each part until every part is sorted.

Each partition step puts the pivot in its final position. The two parts on either side are then sorted the same way, recursively. The average time is O(n log n); a pivot that is always the smallest or largest value degrades it to O(n2).

Answer (d)

Why not others:

  • •(a) — comparing and swapping adjacent pairs pass after pass is bubble sort
  • •(b) — repeatedly finding the minimum and taking it out is selection sort
  • •(c) — inserting each element into its place in an already sorted sequence is insertion sort

Key rule: Match the sort to its core operation: adjacent swaps (bubble), minimum selection (selection), insertion into a sorted part (insertion), pivot and partition (quicksort), merging sorted runs (merge sort).

Algorithm and Programming · AI-written, may contain errors

This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.