Programming Fundamentals

Algorithms Behind AI

Connect complexity, search, sorting, recursion, graphs, and sampling to the mechanisms behind modern AI systems. Use the connections to estimate trade-offs and review code, even when an assistant wrote the first draft.

15 notesOpen reading · no login
Programming Fundamentals15notes

THE QUESTION THIS PAGE ANSWERS

ANSWER FIRST

What will the “Algorithms Behind AI” AI learning path help you do?

Connect complexity, search, sorting, recursion, graphs, and sampling to the mechanisms behind modern AI systems. Use the connections to estimate trade-offs and review code, even when an assistant wrote the first draft. The path contains 15 free notes, each centered on one question you can understand and test.

DECISION RULE

Core themes include Complexity: Is This Code Worth It?, Search and Sorting, Recursion and Divide-and-Conquer, Search and Decision.

TRY NEXT

Begin with “Big-O: See at a Glance How Long Code Will Run,” then choose the next note by the task in front of you.

WATCH FOR

Do not optimize for finishing the list. Explaining one trade-off with your own example matters more than opening more titles.

What this route helps you practice

Open the first note

Each chapter follows a class of real decisions. Follow the sequence, or enter at the problem you are solving today.

15notes
01Big-O: See at a Glance How Long Code Will RunDrag the data-size slider and watch O(1), O(log n), O(n), and O(n²) diverge; 10× the data—who barely flinches, who blows up on the spotInteractive4 min02Why Longer Context Costs More: The O(n²) BillThe attention mechanism makes every token look at every token: drag context length and watch compute and the bill climb with the square—why long chats get slow and expensiveInteractive5 min03Binary Search: The Optimal Number-Guessing GamePlay a 1-to-100 number-guessing round and feel the range cut in half each guess; a billion items found in 30 tries—how fast log n really isInteractive5 min04Sorting: Bubble Sort vs Quicksort RaceA head-to-head visual animation of two sorts: watch bubble sort nudge step by step and quicksort leap by partitions; see how lopsided the gap gets once the data growsAnimation5 min05Sorting's Real Face in AI: RerankPassages RAG retrieves can't go in as-is: coarse ranking first, then fine ranking. Tweak the weights yourself and watch candidates reshuffle—feeds and search results work the same wayInteractive5 min06Recursion: Break a Big Job into the Same Smaller JobWalk a directory tree, break down tasks, draw a fractal tree—same playbook: call yourself. Watch an Agent recursively split “build a site” into actionable small jobsInteractive5 min07Divide and Conquer: The Algorithm Behind Context CompressionCompaction in the AI Practicum is really divide and conquer: split a long chat, summarize each chunk, then merge. Run recursive summarization yourself and watch information compress layer by layerInteractive5 min08BFS and DFS: How an Agent Finds Files in a CodebaseWatch two search personalities in a maze animation: sweep layer by layer vs go all the way down one path; Coding Agent grep and web crawlers are variants of bothInteractive5 min09Greedy and Sampling: Two Personalities When AI Picks WordsAlways picking the biggest is greedy decoding; rolling dice by probability is sampling—the algorithms behind Temperature. Compare sentences from both strategies yourselfInteractive4 min10Beam Search: Look a Few Steps Ahead Before ChoosingOne greedy misstep cascades; Beam Search keeps several candidate paths and explores ahead. Interactively compare the sentences each strategy walks, and feel where “think first, then answer” comes fromInteractive6 min11AI Can Solve the Problems—Do You Still Need LeetCode?Honest talk on interviews today: which roles still test algorithms, how hard, and which stopped caring. Tap your target role and find your seatInteractive5 min12The Right Way to Learn Algorithms with AILet it set problems, play examiner, and walk complexity line by line—three ready-to-use prompt templates that turn AI from doing problems for you into practicing with youHands-on3 min13Summary · Five Algorithm Ideas at a GlanceComplexity / search & sorting / recursion & divide-and-conquer / graph search / greedy & sampling—each maps to a real mechanism in AI; take the whole chapter home on one tableRecap4 min14Run a Complexity Checkup on AI-Written CodeThree tiers: have AI self-report complexity, demand one-tier optimization and spell out the cost, then benchmark on large data to verify it isn't bluffingHands-on6 min15Algorithms · 30 Must-Answer QuestionsEach question comes with What they're assessing, Answer framework, and Bonus point: Big-O intuition / binary-search premises / recursion risks / BFS vs DFS / sampling strategy / do they still test algorithms in the AI eraQuiz3 min