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

EasySoon

Find the maximum depth from root to leaf

DFSRecursion

Invert Binary Tree

EasySoon

Swap left and right children of all nodes

TreeRecursion

Validate Binary Search Tree

MediumSoon

Check if tree satisfies BST properties

BSTInorder Traversal

Lowest Common Ancestor

MediumSoon

Find LCA of two nodes in BST

BSTTree Traversal

Binary Tree Level Order Traversal

MediumSoon

Traverse tree level by level

BFSQueue
Trees - DSA Visualizer | AllVisualizer