computer-science/

Algorithms, data structures and the theory every language shares.

10 results
computer-science/merge-sort-how-splitting-a-list-in-half-again-and-again-sorts-it-with.md Merge sort: how splitting a list in half again and again sorts it with far less work How do you sort 10,000 numbers without making millions of comparisons? Merge sort never sorts a big pile. It splits the list until every… 5 min read · 27 Oct computer-science/hash-tables-how-a-computer-finds-one-name-among-thousands-without-chec.md Hash tables: how a computer finds one name among thousands without checking them all Your phone finds one contact among thousands without reading them all. The trick is a hash table: a row of numbered slots and a small… 6 min read · 24 Oct computer-science/stacks-and-queues-why-undo-takes-the-newest-item-and-a-printer-takes-t.md Stacks and queues: why undo takes the newest item and a printer takes the oldest Press undo and the last thing you typed disappears first. Send documents to a shared printer and the first one is printed first. Both are… 5 min read · 20 Oct computer-science/breadth-first-search-how-a-maze-solver-finds-the-shortest-way-out.md Breadth-first search: how a maze solver finds the shortest way out How does a maze solver, or a map app, find the shortest route and not just any route? The answer is breadth-first search: explore every… 6 min read · 17 Oct computer-science/binary-search-how-to-find-one-number-in-a-million-with-20-guesses.md Binary search: how to find one number in a million with 20 guesses Guessing a number between 1 and 1,000,000 sounds like it could take a million tries. With binary search it takes at most 20. Step through a… 4 min read · 14 Oct computer-science/big-o-how-to-tell-if-your-code-will-survive-1-000-times-more-data.md Big O: how to tell if your code will survive 1,000 times more data Your code works on 10 items, then crawls on 10,000. Big O is the short way programmers describe how the number of steps grows as the input… 4 min read · 11 Oct computer-science/recursion-why-fib-30-makes-2-7-million-calls-and-how-a-notebook-fixes.md Recursion: why fib(30) makes 2.7 million calls, and how a notebook fixes it A function that calls itself sounds like an endless loop, but it works when every call gets a smaller problem and one case is simple enough… 5 min read · 8 Oct computer-science/hash-tables-how-python-finds-a-key-without-searching-for-it.md Hash tables: how Python finds a key without searching for it You type `ages["cat"]` and Python answers instantly, even with a million entries. It does not search. It calculates where "cat" must be… 4 min read · 5 Oct computer-science/what-is-an-algorithm-watch-two-recipes-race-to-sort-six-bars.md What Is an Algorithm? Watch Two Recipes Race to Sort Six Bars An algorithm is a recipe so precise that someone who doesn't understand the goal could still follow it and get the right answer. Computers… 10 min read · 1 Oct computer-science/linear-vs-binary-search-why-30-guesses-can-beat-a-billion.md Linear vs binary search: why 30 guesses can beat a billion Need to find one item in a list? You can check every item in turn (linear search), or, if the list is sorted, look at the middle and throw… 10 min read · 1 Oct