Learning Outcomes
At the end of this lecture, you’ll be able to:
- Explain how a PriorityQueue can be used to sort a collection.
- Describe the efficiency of PriorityQueue based sort using big Oh notation.
- Define heapsort and explain how it relates to (and differs from) selection sort.
- Trace the operation of Floyd’s heapify method which builds the heap from bottom up.
- Explain why we can ignore the leaves in heapify process.
- Show there are ⌈ n/2 ⌉ leaves in a complete binary tree.
- Show Floyd’s heapify is a linear time operation.
- Explain and trace the in-place sorting stage of heapsort.
- Implement heapsort efficiently in Java.
- Use PriorityQueue to solve selection problems.
Lecture Plan
In this lecture, we'll cover the following lessons:
- PriorityQueue: Sort⚡
- PriorityQueue: Efficiency of Sort⚡
- Heapsort
- Heapsort: Floyd's Heapify
- Floyd's Heapify: Exercise⚡
- Complete Binary Tree Interlude: Number of Leaves⚡
- Floyd's Heapify: A Linear Time Operation
- Heapsort: In-place Sorting
- Heapsort: Putting it together!⚡
- PriorityQueue Aside: Selection Problem⚡
- PriorityQueue Aside: Linked Tree Representation⚡
Lessons marked with ⚡ contain exercise/activity.