How would a level order tranverse go for this BST?
G
/ \
C H
/ \ \
B E I
/ / \ \
A D F L
/
J
\
K
Preorder: G,C,B,A,E,D,F,H,I,L,J,K
PostorderA,B,D,F,E,C,K,J,L,I,H,G
Levelorder: ?
How would a level order tranverse go for this BST?
G
/ \
C H
/ \ \
B E I
/ / \ \
A D F L
/
J
\
K
Preorder: G,C,B,A,E,D,F,H,I,L,J,K
PostorderA,B,D,F,E,C,K,J,L,I,H,G
Levelorder: ?
Does this belong on the game forum? Also... stick your ascii graphics in code tags so we can tell what they're supposed to be
Away.
Here's some psuo...pseoo...soo...uh...fake code*.
* Neatly pinched from http://www.nist.gov/dads/ when nobody was looking. That was a real win, it saved me from having to actually type it in from memory. Horrors.Code:levelorderAux(tree, level) begin if tree is null, return; if level is 1, then print(tree.root); else if level greater than 1, then levelorderAux(tree.left_subtree, level-1); levelorderAux(tree.right_subtree, level-1); endif end levelorder(tree) begin for d = 1 to height(tree) levelorderAux(tree, d); endfor end
The information given in this message is known to work on FreeBSD 4.8 STABLE.
*The above statement is false if I was too lazy to test it.*
Please take note that I am not a technical writer, nor do I care to become one.
If someone finds a mistake, gleaming error or typo, do me a favor...bite me.
Don't assume that I'm ever entirely serious or entirely joking.