previous | start | next

Observations about Tree Traversals

To print all the keys in a binary search tree in order, we should visit the nodes:

This is called inorder traversal.

For example, the keys() method of the binary search tree symbol table uses a private recursive method that visits the Nodes in preorder, adding them to a Queue or LinkedList.

Question: If the keys of a binary tree are output in inorder: 1 2 3 4 5 6 7, is the tree balanced (i.e., an avl tree)?

Uh, oh. The inorder output tells us nothing about the shape of the tree.



previous | start | next