On this page
Trees, Heaps & Graphs
Prev: Linear & Hashed Structures | Up: algorithms_and_dsa | Next: Problem-Solving Patterns
Rel: Database B-Tree & LSM Indexing
Ref: Wikipedia — Graph Traversal
Tags: #public #prog #programming #dsa #trees #graphs
Contents
- > Trees, Balanced BSTs & B-Trees
- > Binary Heaps (Priority Queues)
- > Graphs, BFS, DFS & Shortest Paths
Trees, Balanced BSTs & B-Trees
- Binary Search Tree (BST): left subtree < node < right subtree. Self-balancing variants (Red-Black, AVL) guarantee $O(\log n)$ height.
- B-Tree / B+Tree: high fan-out balanced trees sized to disk/memory pages — the backbone of relational database indexes and filesystems.
- Trie (Prefix Tree): stores strings character-by-character for $O(\text{length})$ prefix/autocomplete lookups.
Binary Heaps (Priority Queues)
A binary heap is a complete binary tree stored compactly in an array (parent = (i - 1) // 2, children = 2i + 1, 2i + 2):
- Peek min/max: $O(1)$
- Push / Pop min/max: $O(\log n)$
- Used in schedulers, top-$k$ queries, and Dijkstra's algorithm.
Graphs, BFS, DFS & Shortest Paths
Represent sparse graphs with an adjacency list (node -> [neighbors]) and dense graphs with an adjacency matrix.
- BFS (Queue): visits level-by-level; finds the shortest path in unweighted graphs.
- DFS (Stack / Recursion): explores deep branches first; powers cycle detection and topological sorting (DAG dependency resolution).
- Dijkstra's Algorithm (Min-Heap): finds shortest paths in graphs with non-negative edge weights in $O((V + E) \log V)$.
Linked from
Related notes
- tuts/programming/algorithms_and_dsa Linked here; links to this page; shared tags: #dsa, #prog, #programming
- tuts/programming/algorithms_and_dsa/linear_and_hashed_structures Linked here; links to this page; shared tags: #dsa, #prog, #programming
- tuts/programming/algorithms_and_dsa/problem_solving_patterns Linked here; links to this page; shared tags: #prog, #programming
- tuts/databases/design_patterns/indexing_and_storage_engines Linked here
- tuts/c/tutorials/dynamic_array_implementation shared tags: #dsa, #prog
- tuts/c/tutorials/hash_table_from_scratch shared tags: #dsa, #prog
- tuts/programming shared tags: #prog, #programming
- tuts/programming/algorithms_and_dsa/complexity_and_big_o shared tags: #prog, #programming
- tuts/programming/concurrency shared tags: #prog, #programming
- tuts/programming/concurrency/concurrency_vs_parallelism shared tags: #prog, #programming