Trees
- Non-linear data structure
- Hierarchical Data Structure
* Binary Trees and Binary Search Trees ( LHS < ROOT < RHS ) have great applications in daily life and mostly are the focus in interviews
- Traversals
- Types
- Inorder: Left-Root-Right (Left subtree, root, Rigt subtree)
- Preorder: Root -Left-Right
- Postorder: Left-Right-Root
- Implementation
- Base case
- if(root == null){ return; }
- Recursively call the function with root.left and root.right and print the value of the root as per the type of traversal
- The height of a binary tree is the length of the longest path from the root node to a leaf node.