Next: Leftist Heap Operations
Up: No Title
Previous: Implementation with Local Minimum
Building OABST using the Stack Algorithm
Initialize
Q[N]=T[N]
S=empty
Main Loop
while (
!((Q is empty) and
if
and (the top 2 elements have the same levels)
then
Combine the two elements of the Queue Q which are referred
by the top two elements of the Stack
1. Create new internal node
2.
=
StackTop.level - 1
3.
=
StackTop.weight
4.
=
(StackTop-1).letter
5.
=
(StackTop-1).node
6.
=
StackTop.node
Create new Stack element
1.
=
2.
=
3.
=
4.
pop(Stack)
5.
pop(Stack)
6.
else
Remove an element from the front of the queue Q and create a new
stack element
and push it on the top of the Stack:
1.
=
QueueTop.level
2.
=
QueueTop.letter
3.
=
4.
Advance the QTop pointer
End: OABST is built
Sashka Davis;961;icsg6;
1999-01-14