Day 6
Hello peeps! Welcome to Day 6 - Binary Trees and BST
What we learn today?
- Binary Trees:
- A binary tree is a hierarchical structure where each node has at most two children (left and right).
- Terminology: Root, leaf, depth, height, etc.
- Types of Binary Trees:
- Full Binary Tree: Every node has either 0 or 2 children.
- Complete Binary Tree: All levels are fully filled except possibly the last level.
- Perfect Binary Tree: All internal nodes have 2 children and all leaves are at the same level.
- Balanced Binary Tree: Ensures the height of the tree is minimized.
- Binary Search Trees (BSTs):
- A binary tree with the property that each node's left child is less than the node, and each right child is greater.
- Operations: Insert, search, delete.
- Applications: Efficient searching, range queries, and ordered data storage.
- Practice Questions:
- Given a binary tree, find its height.
- Implement a binary search tree with operations: insertion, search, and deletion.
- Implement a binary tree and perform in-order, pre-order, and post-order traversals.
- Check if a given binary tree is a binary search tree.
- Given a binary tree, print all nodes at a given depth.