Data Structures and Algorithms in Python
by Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser
Chapter 9
Priority Queues

Contents
9.1 The Priority Queue Abstract Data Type
9.2 Implementing a Priority Queue
9.2.1 The Composition Design Pattern
9.2.2 Implementation with an Unsorted List
9.2.3 Implementation with a Sorted List
9.3.2 Implementing a Priority Queue with a Heap
9.3.3 Array-Based Representation of a Complete Binary Tree
9.3.4 Python Heap Implementation
9.3.5 Analysis of a Heap-Based Priority Queue
9.3.6 Bottom-Up Heap Construction ![]()
9.4 Sorting with a Priority Queue
9.4.1 Selection-Sort and Insertion-Sort
9.1 The Priority Queue Abstract Data Type
9.1.1 Priorities
In Chapter 6, we introduced the queue ADT as a collection of objects that are added and removed according to the first-in, first-out (FIFO) principle. A company's customer call center embodies such a model in which waiting customers are told “calls will be answered in the order that they were received.” In that setting, a new call is added to the back of the queue, and each time a customer service representative becomes available, he or she is connected with the call that ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access