Interactive simulations, sorting visualizations, and AI-powered quizzes
A Data Structures Visualizer helps students understand complex concepts like trees, graphs, and sorting algorithms through interactive animations. It allows learners to explore these concepts step-by-step and improve their problem-solving skills.
From Binary Trees to Sorting Algorithms, this platform provides a complete visual learn data structures experience — powered by interactive simulations and AI quizzes.
✦ Left subtree values are less than root
✦ Right subtree values are greater than root
✦ Both subtrees are individually valid BSTs
✦ In-order traversal yields a sorted sequence
✦ Search: O(log n) avg, O(n) worst case
✦ Every node has between t−1 and 2t−1 keys (root may have 1)
✦ All leaves appear at the same depth
✦ Keys in a node are stored in sorted order
✦ An internal node with k keys has exactly k+1 children
✦ Search / Insert / Delete: O(log n) guaranteed
✦ Databases (B+ Tree indexes in MySQL, PostgreSQL)
✦ Filesystems (NTFS, HFS+, ext4)
✦ When data lives on disk — wide nodes minimise I/O
BF(node) = +2, BF(left child) ≥ 0
BF(node) = −2, BF(right child) ≤ 0
BF(node) = +2, BF(left child) < 0
BF(node) = −2, BF(right child) > 0
| Tree type | Nodes (n) | Height (h) | Array slots | Wasted slots | Waste % | Linked slots |
|---|---|---|---|---|---|---|
| Complete BT | 7 | 2 | 7 | 0 | 0% | 7×3=21 |
| Balanced BST | 7 | 2 | 7 | 0 | 0% | 7×3=21 |
| Right-skewed | 7 | 6 | 2⁷−1=127 | 120 | 94% | 7×3=21 |
| n-node skewed | n | n−1 | 2ⁿ−1 | 2ⁿ−n−1 | ≈100% | n×3 |
| Feature | Binary Tree | BST | AVL Tree |
|---|---|---|---|
| Search avg | O(n) | O(log n) | O(log n) |
| Search worst | O(n) | O(n) | O(log n) |
| Insert avg | O(log n) | O(log n) | O(log n) |
| Insert worst | O(log n) | O(n) | O(log n) |
| Delete avg | O(log n) | O(log n) | O(log n) |
| Delete worst | O(log n) | O(n) | O(log n) |
| Height guarantee | O(n) | O(n) | O(log n) |
| Self-balancing | No | No | Yes |
| Sorted in-order | No | Yes | Yes |
| Space (array rep) | O(n) if complete | O(2ⁿ) if skewed | O(n) |
| Space (linked rep) | O(n) | O(n) | O(n) |
| Delete complexity | Simple | 3 cases | 3 cases + rebalance |
| Implementation | Simple | Moderate | Complex |
✦ Root at index 0, children at 2i+1, 2i+2
✦ Fast random access by index — O(1)
✦ No pointer overhead per node
✦ Wastes memory for sparse/skewed trees (O(2ⁿ))
✦ Best for complete binary trees
✦ Each node: data + left* + right*
✦ Memory efficient — always O(n) regardless of shape
✦ Pointer overhead: 2 pointers per node
✦ Dynamic — no pre-allocation needed
✦ Works for any tree shape
| Algorithm | Best | Average | Worst | Space | Stable | Notes |
|---|---|---|---|---|---|---|
| Bubble Sort | O(n) | O(n²) | O(n²) | O(1) | ✓ | Simple, educational |
| Selection Sort | O(n²) | O(n²) | O(n²) | O(1) | ✗ | Min swaps (n−1) |
| Insertion Sort | O(n) | O(n²) | O(n²) | O(1) | ✓ | Fast for small/nearly sorted |
| Shell Sort | O(n log n) | O(n log²n) | O(n²) | O(1) | ✗ | Gap-based insertion |
| Merge Sort | O(n log n) | O(n log n) | O(n log n) | O(n) | ✓ | Divide & conquer, guaranteed |
| Quick Sort | O(n log n) | O(n log n) | O(n²) | O(log n) | ✗ | Fastest in practice |
| Heap Sort | O(n log n) | O(n log n) | O(n log n) | O(1) | ✗ | In-place, guaranteed |
| Counting Sort | O(n+k) | O(n+k) | O(n+k) | O(k) | ✓ | Integers only, k=range |
| Radix Sort | O(nk) | O(nk) | O(nk) | O(n+k) | ✓ | Digit-by-digit, k=digits |
| Operation | Array | Linked List |
|---|---|---|
| Push | O(1) | O(1) |
| Pop | O(1) | O(1) |
| Peek / Top | O(1) | O(1) |
| Search | O(n) | O(n) |
| Space | O(n) — fixed | O(n) — dynamic |
✦ Function call stack — return addresses, local vars
✦ Undo / Redo — history in text editors
✦ Expression evaluation — infix to postfix
✦ Backtracking — DFS traversal, maze solving
✦ Balanced parentheses — compiler syntax check
| Operation | Array | Linked List |
|---|---|---|
| Enqueue | O(1) | O(1) |
| Dequeue | O(1) | O(1) |
| Front peek | O(1) | O(1) |
| Space | O(n) fixed | O(n) dynamic |
| Wasted space | Yes (linear) | No (circular) |
✦ BFS traversal — level-by-level graph/tree walk
✦ CPU scheduling — round-robin process queue
✦ Printer spooler — jobs wait in order
✦ Network buffers — packet queuing in routers
✦ Producer-consumer — inter-thread communication
| Feature | Singly | Doubly |
|---|---|---|
| Pointers / node | 1 (next) | 2 (prev+next) |
| Memory / node | Less | More |
| Reverse traversal | No | Yes |
| Delete given ptr | O(n) | O(1) |
| Insert at head | O(1) | O(1) |
| Insert at tail | O(n)* | O(1) w/ tail* |
✦ Insert at head: O(1) always
✦ Insert/delete at tail: O(1) with tail pointer
✦ Random access: O(n) — no index math
✦ Search: O(n) — must traverse
std::map, Java TreeMap, and Linux process scheduler.
| Operation | BST (avg) | BST (worst) | Red-Black |
|---|---|---|---|
| Search | O(log n) | O(n) | O(log n) |
| Insert | O(log n) | O(n) | O(log n) |
| Delete | O(log n) | O(n) | O(log n) |
| Height | O(log n) avg | O(n) skewed | ≤ 2·log₂(n+1) |
| Rotations per insert | — | — | ≤ 2 |
| Property | Separate Chaining | Linear Probing |
|---|---|---|
| Insert (avg) | O(1) | O(1) |
| Search (avg) | O(1+α) | O(1/(1−α)) |
| Delete | O(1) | Lazy deletion |
| Load factor limit | α can > 1 | Must be < 1 |
| Cache performance | Poor (pointers) | Excellent (array) |
| Clustering | No | Primary clustering |
| Extra memory | For linked nodes | None |
✦ Prime numbers (11, 13, 17…) reduce clustering and collisions.
✦ With a composite size (e.g. 12), multiples of 3 always map to indices 0, 3, 6, 9 — creating hotspots.
✦ A prime size ensures better distribution: gcd(step, size) = 1 guarantees full coverage during probing.
| Property | Adjacency Matrix | Adjacency List |
|---|---|---|
| Space | O(V²) | O(V+E) |
| Edge check | O(1) | O(degree) |
| Add edge | O(1) | O(1) |
| Get neighbors | O(V) | O(degree) |
| Best for | Dense graphs | Sparse graphs |
| BFS/DFS | O(V²) | O(V+E) |
✦ BFS → shortest path (unweighted) — social network degrees
✦ DFS → cycle detection — dependency graph validation
✦ DFS → topological sort — build systems, course scheduling
✦ Dijkstra → weighted shortest — GPS routing (A* variant)
✦ Connected components — use DFS or Union-Find
Each node stores a single character. Shared prefixes reuse nodes → fast word lookups, autocomplete, and spellchecking.
Complete binary tree maintaining the heap invariant parent ≤ children (Min-Heap) or parent ≥ children (Max-Heap). Priority Queue stores (priority, value) pairs.