Efficient Priority Queues
Title Page
Linear Implementations
java.util.PriorityQueue
Binary Heaps
Heap Efficiency
Heap Implementation
Linear implementations of priority queues can use
arrays
or
linked lists
.
Array Implementation
Linked Implementation
Wanted
Adding Near End
Adding Near Beginning
Removing
Removing
Adding
Heap Property
BSTs as PQs
Heaps as PQs
Removing
Adding
Heapifying 1
Heapifying 2
Heapifying 3
Heapifying 1
Heapifying 2
Heapifying 3
Heapifying 4
Heapifying 5
Heap Height
Proof
Advantage
We would like to show that the height of a balanced binary tree of size
n
is
O(log n)
.
Proof 1
Proof 2
Proof 3
Proof 4
Proof 5
Proof 6
As Array
Operations
Optimizations
Array 1
Array 2
Array 3
Array 4
Array 5
Parent
"There are 10 kinds of people in the world: Those who understand BINARY and those who don't"
Bit Shift Left
Bitwise OR
Bit Shift Right