Algorithms
If you want to solve a puzzle and you dump the pieces out on a table, where do you start? You probably break it down into steps— look for the edge pieces, put those in a pile, arrange them into the border, then start grouping the other pieces by color and into small chunks that you attach to the edges until slowly but surely you’re done.
You’ve just problem-solved by breaking down a problem into simpler steps to find the most efficient way to come to a solution.
An algorithm is similarly nothing more than a set of instructions — the steps it takes to accomplish something. It’s a fancy word for instructions. A recipe is an algorithm. The assembly instruction booklet for your IKEA table is an algorithm. Swimming is an algorithm.
Everyday
We all use algorithms in our everyday lives. Our brain is one big algorithm machine.
When you look at a restaurant menu, how do you do it? Do you first quickly scan top to bottom, left to right over the entire thing while making a mental note of the top 3 areas you want to look at more closely, then focus on those 3? Do you pick 3 from those options and then make a choice? That’s an algorithm.
When you choose a song on the radio, do you stop when you hear one that’s good enough or do you go through all your presets and come back to your favorite choice? That’s another algorithm. Your process of choosing a movie on Netflix works in the same way. What do you do when you need to park at a mall? Drive toward the entrance, keeping track of all the open spots you see as you make your way there. You can adjust a variable, such as how important it is to be close to the entrance. You don’t see a spot close to the entrance, so you track back looking for the previous spots you’ve noticed that are further away.
How do you find a wife? Consider the ‘Secretary Problem’:
The basic form of the problem is the following: imagine an administrator who wants to hire the best secretary out of x number of rankable applicants for a position. The applicants are interviewed one by one in random order. A decision about each particular applicant is to be made immediately after the interview. Once rejected, an applicant cannot be recalled. During the interview, the administrator can rank the applicant among all applicants interviewed so far, but is unaware of the quality of yet unseen applicants. The question is about the optimal strategy (stopping rule) to maximize the probability of selecting the best applicant. If the decision can be deferred to the end, this can be solved by the simple maximum selection algorithm of tracking the running maximum (and who achieved it), and selecting the overall maximum at the end. The difficulty is that the decision must be made immediately.
In other words, you date serially (one potential mate after the other) and have to choose if you want to be with that person without being able to ‘interview’ any more candidates. What is your stopping rule? The general consensus is to date 6 people, find the one you like best and the next one you meet that matches that person — marry them.
Technology
When people say they’re ‘coding’ they’re not. They’re ‘algorithming’ — they are creating steps and interactions based on inputs and variables.
All the advances in technology are algorithms — they go together. Artificial Intelligence is just a set of very complicated algorithms.
When you next get in an Uber, ask yourself how their algorithm matches rides? Through their app, you can find out how long it will take to get to your destination, how close your nearest driver is, and how much your trip will cost you. These things don’t just happen. They’re coded as a set of algorithms.
Examples
Compression
How do you take a file and make it smaller without losing information?? This is an algorithm where typically the algorithm will look for patterns in the file and build a table of where those patterns are that are much smaller than the actual file. See ‘How File Compression Works’ on howstuffworks.
Search
Google is an algorithm. The only thing separating it from other search engines is its far superior algorithm. Sergey Brin and Larry Page solved that problem much better than anyone else.
Blockchain
The Blockchain (think about bitcoin) is just an algorithm that updates one database across a variety of machines (nodes) at one time using another algorithm called the general consensus algorithm.
News Feed
Consider the Facebook news feed:
The algorithm behind the News Feed is regularly tweaked and historically opaque — it is one of the most significant and influential pieces of code ever written. You can think of the algorithm as the News Feed Editor. — Tobias Rose-Stockwell, ‘This is How Your Fear and Outrage Are Being Sold for Profit’, 2017
People spend years trying to figure out the algorithm that determines Google results. Similarly, people dedicate their time and energy to trying to calculate how to get to the top of Reddit.
Public Private Key Exchange (Cryptography)
I can input my credit card information into a browser and send it across the world without anybody being able to steal it. That’s completely possible due to an insanely genius algorithm that was solved in the 1970s.
There are many, and many are very complex. We owe a great deal of the ease of our lives to very brilliant people solving very difficult problems and inventing solutions for them — nth binary trees, hashtable lookups, abstract syntax trees. The type of shit they ask you in interviews at google.
Thinking algorithmically requires being very specific and detail oriented — exactly what computers need. We can’t be vague with computers, we have to tell them exactly what to do and algorithms are how we do it.
There is a fantastic documentary that explains algorithms in a fun, digestible way better than I ever could here. It’s also available on Netflix.
Trailer:
Full Movie: