{ }
</>
[ ]
!=
#

Tree Visualizer

Structures & Algorithms

Comprehensive guide to Tree variations, Heap properties, and Graph algorithms.

Tree Classifications

A
B
C

Full Binary Tree

Every node has either 0 or 2 children.

Used in Huffman Coding

1
2
3
4
5

Complete Binary Tree

Filled level-by-level, left-to-right.

Basis for Binary Heaps

R
L
R

Perfect Binary Tree

All internal nodes have 2 children, leaves at same depth.

Nodes = 2^(h+1) - 1

Balanced Structures

BST

Binary Search Tree

Unbalanced

Standard ordering: Left < Parent < Right.

AVL

AVL Tree

Self-Balancing

Strictly balanced (height diff ≤ 1). Guaranteed O(log n) lookups.

RB

Red-Black Tree

Self-Balancing (Color Properties)

Enforces balance via color rules (Red/Black).
• No two red nodes adjacent.
• Black-height uniform paths.

Pros: Faster insertion/deletion than AVL due to fewer rotations.

Algorithms

DFS Traversals

  • Preorder: Root → Left → Right
  • Inorder: Left → Root → Right
  • Postorder: Left → Right → Root

BFS (Level Order)

Explores neighbors layer by layer using a Queue. Finds shortest path in unweighted graphs.

Queue-based

Minimum Spanning Tree

  • Prim's: Greedy node-based approach. Grows from start node.
  • Kruskal's: Greedy edge-based approach using Union-Find to avoid cycles.