 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| • |
To
insert an item, we use just the opposite
|
|
|
|
strategy.
|
|
|
|
– |
We
insert at the bottom of the tree and trickle the
|
|
|
|
number
upward to be in the proper place.
|
|
|
|
– |
With
insert, the number of swaps cannot exceed the
|
|
|
|
height
of the tree -- so that is the worst case!
|
|
|
|
– |
Which,
since we are dealing with a binary tree, this is
|
|
|
|
always
approximately log2(N) which is very efficient.
|