Priority queue

Published

2023-08-05

A priority queue is a little different from the simple queue we saw earlier. A priority queue allows elements in the queue to be prioritized, so that elements are dequeued in accordance with their priority. Priority queue is often implemented with binary heap—either min heap or max heap—since this data structure is so well-suited to the application. Here we demonstrate a priority queue using max heap.

Once you’ve watched this video, ask yourself these questions:

Supplemental materials

Resources

Comprehension check

  1. If each child has a value less than or equal to that of the parent then we have a _____ heap.
  2. When percolating down in a max heap we swap the position of the bubble with that of the ________-valued child (or leftmost child if both children have the same value)
  3. The primary operations for a priority queue with min heap are delete min and ________________.
  4. All heap operations must preserve the ______________ property and the ____________ property.

Answers: (ǝdɐɥs ɹo) ǝɹnʇɔnɹʇs ’ɹǝpɹo dɐǝɥ ’ʇɹǝsuᴉ ’ʇsǝƃɹɐl ’xɐɯ

Original author: Clayton Cafiero < [given name] DOT [surname] AT uvm DOT edu >

No generative AI was used in producing this material. This was written the old-fashioned way.

All materials copyright © 2020–2023, The University of Vermont. All rights reserved.