Algorithm Scriptures — Turning Tales into Tools

Where Tales Become Tools

The scroll-room that sits behind every story.

In the Gurukul and across the Kingdom, you meet algorithms as stories: burning bazaars, echo caverns, royal halls. The Scriptures are the place where those stories are distilled into definitions, invariants, and code.

Use the Scriptures when you want to:
  • Turn a remembered scene into an implementable pattern.
  • Review complexity and edge-cases before an interview.
  • See how different stories share the same underlying idea.
Story first, scripture second.
The tales are for intuition and memory. The Scriptures are for precision. You’re allowed to re-read the story, then come here when your brain is hungry for the formal stuff.
Foundation Scrolls — Gurukul
Core Patterns You’ll See Again and Again

These scrolls correspond to the twelve Gurukul episodes — but they’re written to stand alone. Think of them as algorithm reference pages anchored to very specific stories you’ve already seen: markets, caverns, libraries, ancestral halls, burning bazaars, and more.

Scroll I
Arrays & Linear Thinking
Walking the line, one step at a time.
How to reason about contiguous memory, indices, off-by-one traps, prefix operations, and simple passes over data. This is the walking pace of most algorithms.
Concepts: arrays, iteration patterns, prefix logic, boundaries.
Read the array scripture ↗
Scroll II
Two-Pointer Patterns
Guards at opposite gates.
When scanning from both ends beats brute force. Patterns for pair sums, palindromes, partitioning, and shrinking ranges with two moving indices.
Concepts: opposite pointers, convergence, partitioning, O(n) vs O(n²).
Read the two-pointers scripture ↗
Scroll III
Sliding Window
Managing limited attention over time.
Subarrays and subranges under constraints: fixed and variable windows, counting vs optimizing, and how to move the window without recomputing everything.
Concepts: windows, running counts, amortized O(n), time-boxed state.
Read the sliding window scripture ↗
Scroll IV
Greedy Algorithms & Scheduling
Local choice, global gain — when it works.
The rule “pick what finishes earliest” in a crowded schedule, and why some problems love greedy rules while others punish them.
Concepts: greedy choice, interval scheduling, proofs of correctness, counterexamples.
Read the greedy scheduling scripture ↗
Scroll V
Sorting Basics
Everything is chaos until you impose order.
Selection vs insertion sort, stability, complexity, and why “sorting first” is secretly the answer to an absurd number of problems.
Concepts: O(n²) basics, comparison model, when pre-sorting unlocks simpler logic.
Read the sorting scripture ↗
Scroll VI
Hash Maps
The Hall of Thousand Doors.
Key → slot → value. Constant-time lookup in theory, what collisions actually mean, and how hash maps simplify counting, grouping, and memoization tasks.
Concepts: hashing, buckets, collisions, average O(1), typical pitfalls.
Read the hash map scripture ↗
Scroll VII
Binary Search
Jump to the middle first.
More than “guess the number”: searching on value space, lower/upper bounds, and how to reason about invariants while halving the search region.
Concepts: sorted domains, invariants, bounds, log n steps.
Read the binary search scripture ↗
Scroll VIII
Recursion & the Call Stack
When the problem calls a smaller copy of itself.
Base cases, shrinking steps, and how to picture the call stack as a vertical cavern of echoes instead of black magic that “just works”.
Concepts: base case, recurrence, stack frames, stack overflow.
Read the recursion scripture ↗
Scroll IX
Trees & Traversals
Roots, branches, and visiting order.
Binary trees as royal lineages: parents, children, depth, and the difference between preorder, inorder, and postorder passes.
Concepts: tree shapes, traversal orders, recursion patterns on trees.
Read the trees scripture ↗
Scroll X
Priority Queues & Heaps
What truly matters first.
The Burning Bazaar formalized: heap structure, push / pop operations, and why “always handle the most important thing next” is a powerful abstraction.
Concepts: heap shape, heap property, insert / extract, typical uses.
Read the heap scripture ↗
Scroll XI
Backtracking
Exploring and undoing, without shame.
Systematic trial and error: decision trees, marking choices, undoing state, and pruning branches that can’t possibly lead to a valid solution.
Concepts: search trees, state restore, pruning, exponential spaces.
Read the backtracking scripture ↗
Scroll XII
Divide & Conquer
Splitting mountains into climbable pieces.
How to split a big problem into independent subproblems, solve them recursively, and merge the answers — from merge sort to more creative decompositions.
Concepts: problem decomposition, merge step, recursion trees, T(n) recurrences.
Read the divide & conquer scripture ↗
How to Use This Library
When to Read Stories, When to Read Scrolls

After the tale, before the interview.

The ideal flow is simple: read a story, notice the pattern, then open the matching Scripture to cement the algorithm. When you later face a real problem, you’re recalling both the scene and the formal pattern.

  • Stuck in a story? Jump here mid-way to see the core idea, then return to the narrative.
  • Before coding practice? Skim 1–2 scrolls to refresh patterns you keep forgetting.
  • Before interviews? Use scrolls as a lightweight revision sheet: complexity, invariants, edge cases.
  • Teaching others? Point juniors to the story first, then hand them the Scripture as a “lab manual”.
Under the Night Sky of Ideas

New scrolls are being written.

As new tales appear in the kingdom, their matching Scriptures will show up here — more patterns, more proofs, more checklists. Join the list if you want those updates without having to patrol the library yourself.

Pure algorithms and reasoning. No “10x grindset”, no hustle sermon.