LOGBOOK

HELP

Quiz Entry - updated: 2026.12.01

How does a priority queue implemented with a sorted list perform, and which sorting algorithm does PQ-Sort become with it?

min and removeMin are $O(1)$ because the smallest key is always at the front, but insert is $O(n)$ because the correct position must be found. PQ-Sort with it is insertion-sort, $O(n^2)$.

This is the mirror image of the unsorted list. Keeping the list in ascending order means the minimum is always the first element, so reading or removing it is immediate. The cost moves to insert: the new entry must be placed between its neighbours, and finding that spot can take a walk through the whole list.

In PQ-Sort, phase 1 now does all the work: each element is inserted into its correct place in the already sorted part, which is insertion-sort, again $1 + 2 + \dots + n = O(n^2)$ in the worst case. Phase 2 simply reads the list off from the front.

insert min, removeMin PQ-Sort becomes
Unsorted list $O(1)$ $O(n)$ selection-sort
Sorted list $O(n)$ $O(1)$ insertion-sort

Each list makes one side cheap by making the other side linear. A heap avoids that trade by making both sides logarithmic.

Go deeper:

  • doc Insertion sort — the algorithm PQ-Sort becomes with a sorted list, with an animation.

From Quiz: ADS / Priority Queues and Heaps | Updated: Dec 01, 2026