Skip to main content

Module 1: Algorithm Intuition & Visualization

Primary text: Grokking Algorithms (Aditya Bhargava, selected chunks from Chapters 1-6)

This guide is the primary teacher. You do not need to read Grokking Algorithms front-to-back to complete the module. The main path teaches the concepts directly, then asks you to trace, compare, and build with them. Source reading is only for clarification or extra depth.


Scope of This Module

This module is intentionally not a full-book rewrite of Grokking Algorithms.

It uses the early, highest-leverage parts of the book to build first-pass algorithm intuition during Orientation. The goal here is to make algorithmic thinking feel concrete and usable, not to exhaust every topic in the source text during Semester 0.

What this module deliberately covers now:

  • binary search as a first example of eliminating possibilities
  • Big O as growth intuition
  • arrays, linked lists, and hash tables as storage tradeoffs
  • recursion and the call stack as problem decomposition intuition
  • sorting as a contrast between repeated full scans and divide-and-conquer
  • graphs and breadth-first search as first-pass path and dependency reasoning

What this module deliberately defers:

  • weighted shortest paths such as Dijkstra's algorithm
  • greedy algorithms
  • dynamic programming
  • k-nearest neighbors and the book's machine-learning-flavored chapter
  • trees and later advanced-topic survey material

Those topics matter, but they belong in later algorithm and data-structure work after this intuition layer is stable.


Before You Start

Close everything and answer these from your current understanding:

  1. If a list is already sorted, what faster search move becomes available?
  2. When someone says one algorithm is "faster," what might that mean besides stopwatch time?
  3. If you need to look up a username instantly, what kind of data shape would help?
  4. What has to be true before a recursive function can safely call itself again?
  5. If you need the fewest steps between two connected things, what picture would you draw first?

If your answers are fuzzy, that is expected. This module is designed to make them concrete.


What This Module Is For

This module gives you a first working feel for algorithms before later semesters ask for formal data structures, proofs, or harder problem solving. The target is not "memorize famous algorithms." The target is to see what makes an algorithm a good fit:

  • some algorithms win by eliminating possibilities faster
  • some wins come from the way data is stored, not just the code you write
  • some problems become manageable only after you break them into smaller cases
  • some problems are easiest once you model the world as a graph

By the end, you should be able to trace the logic of a few classic algorithms, explain their tradeoffs in plain language, and produce one small visualization or implementation artifact.


Concept Map

The order matters. First learn how faster search works, then how growth changes decisions, then how storage shape creates tradeoffs, then how recursion shrinks problems, then how sorting exposes different algorithm shapes, and finally how graph thinking unlocks shortest-path reasoning.


How To Use This Module

Use the concept pages first. They are the primary path. Then do the practice pages. Open the reference section only if a concept still feels fuzzy or if you want the original source framing.

This module now uses light cluster organization so the concept sequence is easier to scan and maintain.

Cluster 1: Search and Growth

OrderConceptTypeFocus
1Search by Eliminating Half the PossibilitiesPRIMARYBinary search, sorted inputs, and why halving changes everything
2Growth Rate Beats Raw TimingSUPPORTINGBig O as input-growth reasoning, not stopwatch worship

Cluster mastery check: Can you explain why sorted order enables binary search and why O(log n) and O(n) diverge hard as input grows?

Cluster 2: Data and Decomposition

OrderConceptTypeFocus
3Data Shape Controls What Feels FastPRIMARYArrays, linked lists, and hash tables as tradeoff choices
4Break Big Problems Into Smaller OnesSUPPORTINGRecursion, base cases, smaller subproblems, and the call stack
5Sorting Reveals Algorithm ShapeSUPPORTINGSelection sort vs quicksort, repeated scans vs partitioning

Cluster mastery check: Can you choose a data shape by operation, explain a recursive base case, and compare repeated scanning against divide-and-conquer sorting?

Cluster 3: Graph Thinking

OrderConceptTypeFocus
6Think in Graphs, Then Search Breadth-FirstPRIMARYNodes, edges, queues, shortest paths, and dependency order

Cluster mastery check: Can you draw a small graph and explain why BFS needs a queue plus a visited rule?

Then work these:

OrderPractice pathFocus
1Trace Search and Data TradeoffsExplain and compare search, growth, and storage choices
2Trace Recursion and Sorting by HandHand-trace recursion, selection sort, and quicksort without hiding behind code execution
3Build a Graph and Explain the PathModel a small network and use BFS or dependency ordering to reason about it

Use Module Quiz after the concept and practice pages. Use Book Exercise Lanes when you want more repetition from the local book chunks. Use Learning Resources and Reference and Selective Reading only when you need targeted source support.


Learning Objectives

By the end of the module you should be able to:

  1. Explain why binary search is faster than simple search and when it is valid to use.
  2. Compare O(1), O(log n), O(n), O(n log n), and O(n^2) at a practical intuition level.
  3. Choose between an array, linked list, and hash table based on the dominant operation you care about.
  4. Identify a base case and recursive case, then trace how the call stack changes during a small recursive algorithm.
  5. Explain the difference between a repeated-scan sort like selection sort and a divide-and-conquer sort like quicksort.
  6. Model a shortest-path or dependency problem as a graph and explain why a queue matters in breadth-first search.

Outputs

  • one binary-search trace on a sorted list
  • one short Big O comparison note using a real scenario
  • one data-structure choice table for at least three scenarios
  • one hand-worked recursion trace showing base case, recursive case, and stack behavior
  • one sorting comparison note or hand trace contrasting selection sort and quicksort
  • one small graph artifact with either a shortest path or a valid dependency order
  • one small implementation or annotated pseudocode snippet, ideally with at least one assertion if you use code

Completion Standard

You have completed Module 1 when all of these are true:

  • you can explain why sorted order matters for binary search
  • you can describe Big O as growth behavior, not exact clock time
  • you can choose a data structure by naming the operation you are optimizing for
  • you can identify the base case and recursive case in a small recursive example
  • you can explain why selection sort and quicksort do different kinds of work
  • you can explain what quicksort is doing when it picks a pivot and partitions
  • you can draw a small graph and explain how breadth-first search finds the shortest unweighted path or why a dependency order is valid
  • you have produced at least one real trace, note, diagram, or code artifact instead of only reading

If you understand the words but cannot trace or produce anything concrete, the module is not complete yet.


Reading Policy

  • Read only if stuck means the guide should be enough for most learners.
  • Optional deep dive means extra nuance, not required progress.
  • If the concept pages and practice pages are complete, you have made real progress even without reading the full source text.

What This Module Does Not Cover Yet

If you open the Grokking Algorithms contents and notice more chapters than this module teaches, that is expected.

This module does not try to finish the entire book in Semester 0. It is a boundary-setting module for algorithm intuition. Later algorithm-focused semesters are the right place for:

  • weighted graph reasoning and shortest paths beyond BFS
  • greedy choice strategies and approximation thinking
  • dynamic programming as structured subproblem optimization
  • classification and similarity intuition from k-nearest neighbors
  • trees and more advanced data-structure families

So if the module feels smaller than the full book, that is not automatically a population failure. It is an intentional scope choice.


Suggested Weekly Flow

DayWork
1Concepts 1-2 and one hand trace of binary search
2Concept 3 and a data-structure tradeoff table
3Concept 4 and one recursion trace
4Concepts 5-6 and one sorting note plus one small graph drawing
5Practice page 1 and practice page 2
6Practice page 3, refine one artifact, and open the reference section only where still needed

Reference

If you want targeted source chunks or a concept-to-source map, use Reference and Selective Reading.


Rich Learning Pages

Worked Examples | Guided Labs | Case Studies | Mistake Clinic | Reading Guide | Capstone Thread