COMP 206 Lecture Notes - Lecture 19: Tree Traversal, Binary Tree, Preorder

17 views8 pages

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.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents