COMP 206 Lecture Notes - Lecture 19: Tree Traversal, Binary Tree, Preorder
Document Summary
Binary tree: each node has, at most, two children. Every node can have a left child or a right child. In the picture above, the height is 3. << this is a very important formula thing! You don"t use a linked list for the children, you don"t use a first child/next sibling. Because you have only two children, you call the children leftchild and rightchild. class btree{ The inner class is binary tree node which has a left and right child. The tree itself has a root reference, so it points to a root node. The root node will point to other nodes, and so forth, just like with a linked list. In the last lecture , we talked about depth first and breadth first root traversal, pre-order and post-order. Pre-order traversal: you visit each node before visiting its children.