Swipe to navigate through the chapters of this book
This chapter begins by first examining heaps. Then it looks at how heaps can be used to create priority queues followed by how they can also be used to create the heap sort. Although both are implemented using arrays, drawings of both trees and arrays are included to help illustrate the concepts. After introducing the priority queue a test program is included. Then the heap sort is introduced first as a simplified sort and then modified to show the complete heap sort is implemented. Lastly, a complete program simulating how a priority queue might be used in printing is presented.