- flip the output of avl tree (swap left with right children in output to mimick the output given by red-black tree)

pull/51/head
Emir Pasic 9 years ago
parent bf32da08f2
commit 42299026d8

@ -421,14 +421,14 @@ func (n *Node) walk1(a int) *Node {
} }
func output(node *Node, prefix string, isTail bool, str *string) { func output(node *Node, prefix string, isTail bool, str *string) {
if node.Children[0] != nil { if node.Children[1] != nil {
newPrefix := prefix newPrefix := prefix
if isTail { if isTail {
newPrefix += "│ " newPrefix += "│ "
} else { } else {
newPrefix += " " newPrefix += " "
} }
output(node.Children[0], newPrefix, false, str) output(node.Children[1], newPrefix, false, str)
} }
*str += prefix *str += prefix
if isTail { if isTail {
@ -437,13 +437,13 @@ func output(node *Node, prefix string, isTail bool, str *string) {
*str += "┌── " *str += "┌── "
} }
*str += node.String() + "\n" *str += node.String() + "\n"
if node.Children[1] != nil { if node.Children[0] != nil {
newPrefix := prefix newPrefix := prefix
if isTail { if isTail {
newPrefix += " " newPrefix += " "
} else { } else {
newPrefix += "│ " newPrefix += "│ "
} }
output(node.Children[1], newPrefix, true, str) output(node.Children[0], newPrefix, true, str)
} }
} }

Loading…
Cancel
Save