Trees
Explore binary trees, BST, and tree traversals
Trees are hierarchical data structures with a root node and child nodes forming a parent-child relationship. Binary trees, BSTs, AVL trees, and heaps are fundamental for efficient searching, sorting, and hierarchical data representation.
Key Concepts
- Hierarchical structure with root and leaf nodes
- Binary Search Tree: Left < Parent < Right
- Traversals: Inorder, Preorder, Postorder, Level-order
- Self-balancing trees: AVL, Red-Black for O(log n)
- Heaps for priority queue implementation
Problems
Maximum Depth of Binary Tree
EasySoonFind the maximum depth from root to leaf
DFSRecursion
Invert Binary Tree
EasySoonSwap left and right children of all nodes
TreeRecursion
Validate Binary Search Tree
MediumSoonCheck if tree satisfies BST properties
BSTInorder Traversal
Lowest Common Ancestor
MediumSoonFind LCA of two nodes in BST
BSTTree Traversal
Binary Tree Level Order Traversal
MediumSoonTraverse tree level by level
BFSQueue