 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| • |
The
real advantage of a heap is that it is
|
|
|
always
balanced.
|
|
|
|
– |
It
makes a heap more efficient for
|
|
|
implementing
a priority queue than a binary
|
|
|
search
tree because the operations that keep a
|
|
binary
search tree balanced are far more
|
|
|
complex
than the heap operations.
|
|
|
|
– |
However,
heaps are not useful if you want to
|
|
|
try
to traverse a heap in sorted order -- or
|
|
|
retrieve
a particular item.
|
|