# CS 112

Lecture 22

##
Tree Traversal and Applications

- Tree traversal algorithms, sketch. Left node Right, Left
Right node traversals.
- Help with Hw10: the design of the BTree class.
Discuss how to implement Print by traversing the tree.
Discuss how to correctly implement the
delete functions, which need to deallocate a whole subtree, and this
needs traversal.
Also observe that insert may overwrite a subtree,
which will be then left unused: then it should also be
deallocated.
**Applications:** Binary arithmetic expression trees and Binary
search trees.
- Binary arithmetic expresion trees. From a fully parenthesized expression
to a binary expression tree to an arithmetic expression in
postfix form.
- Definition of binary search trees.
- Application of binary tree traversal for search trees: Sorting using
binary search trees.

Ileana Streinu