This is an old revision of the document!


Section 2.5 Priority Queues

Statement 2.11 from the book says that “a sequence of O(n) priority queue operations can be used to sort a set of n numbers”. This is because the set of numbers can be inserted into it with their value as their priority and then extracted in order of priority, resulting in their being in sorted order. I wondered when reading this, then, why we can not come up with a linear sort algorithm? I know I must be missing something but why is this not a linear sort?

Regardless, we will use a heap to implement our priority queue. The heap is an array with an object at position i, its left child at 2i and its right child at 2i+1.

courses/cs211/winter2018/journals/holmesr/section_2.5.1517200446.txt.gz · Last modified: by holmesr
CC Attribution-Noncommercial-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0