The Function Sort |
|
|
|
Moves all keys from the heaptree into the result list.
| Explicit parameters: | - (none). |
| Implicit parameters: | Heaptree, result list. |
Heaptree: complete, completely filled and heapordered.
Result list: empty.
|
|
Heaptree: empty.
Result list: ascending order and completely filled.
|
|
| Function (Parameter) | Short description | Precondition |
|---|---|---|
| Move-Max () | Moves the maximum key from the heaptree to the result list. |
Heaptree: complete and heapordered. Result list: ordered ascendingly. |
Move all keys into the result list.
Permitted sequences: There is only one valid sequence for this function.
The standard procedure: Move-Max removes the greatest key from the heaptree and inserts it in front of the elements of the result list. Move-Max is called as many times as there are keys in the heaptree. This generates an ascending sorted list.
Run time: Move-Max: Number of nodes.
Correctness: Follows from the correctness of move-max.
|
|
|
|