- A binary tree consists of a root.
- A root can be empty or it can have two parents as a child.
- A parent can either be empty or it can have two parents as a child.
So, a tree will have a root, which may or may not have a left and a right child. Moreover, those child nodes may or may not be parents. We also learned three ways of traversing a tree. Which are preorder, postorder and inorder traversal.
Here is how each of them traverse recursively:
Preorder
- root
- left
- right
Postorder
- left
- right
- root
Inorder
- left
- root
- right
-----------more will be added soon-----------
No comments:
Post a Comment