Trees

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 points

  • 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

Coming soon

Find the maximum depth from root to leaf

DFSRecursion

Invert Binary Tree

Coming soon

Swap left and right children of all nodes

TreeRecursion

Validate Binary Search Tree

Coming soon

Check if tree satisfies BST properties

BSTInorder Traversal

Lowest Common Ancestor

Coming soon

Find LCA of two nodes in BST

BSTTree Traversal

Binary Tree Level Order Traversal

Coming soon

Traverse tree level by level

BFSQueue