– What is an algorithm?


– What is an algorithm?

In: 8

An algorithm is a series or parallel set of steps (often both) which can be followed to produce a specific result. Several analog examples of algorithms exist, but probably the most widely known are recipe cards and the description of a moving assembly line. Note when you are actually doing the thing, you are executing the algorithm, while the algorithm itself describes what you will so. In most cases, the term algorithm is used to apply to computer systems and other digital processes, rather than their analog counterparts. When one speaks of the YouTube algorithm, as an example, they are speaking of particular portions of the YouTube system which take a series of inputs (video, viewing data, likes, comments, subscriptions, rate of such activity over time, etc, etc) to produce particular outputs (recommending videos in “popular” or to specific viewers or at particular times of day or year).

It is also possible to think of an algorithm, especially secret algorithms, as a black box where you dump certain components into it, and a fancy new product comes out the other end.

It’s literally just a set of instructions, usually math based. It’s what order to perform certain calculations in. When you hear about something like “the YouTube algorithm”, they are assigning different weights and metrics to videos based on your watch time and what you watch, and then run a series of calculations to compare that to what other users are watching. The goal is to go “well you like physics content and watch a lot of Physics Girl and Action Lab. Other people that watch Physics Girl and Action Lab also enjoy these creators / topics.”

It is a process of computational rules which is designed to operate on some input of data to calculate and return some desired output. (E.g., a computer program that returns a statistical distribution of a list of birthdays, or a sorted list of names, or determines the “best” next play in a hand of blackjack.)

I use “computational” very generally here to describe rules that are rigorously bounded by logic–not rules that require a literal computer. If you were tasked to physically sort people in a queue according to rules and criteria written on a piece of paper, those written instructions could be fairly said to be an algorithm.

It’s just a set of steps, a set of instructions.

This is an algorithm.
1. Take off your clothes
2. Get into the bathtub.
3. Turn on the water
4. Soap up your body
5. Scrub!
6. Rinse all the soap off
7. Turn off the water
8. Step out of the tub
9. Dry off with a towel

That’s a simple one, but there are algorithms for doing some pretty complicated things:

* There’s an algorithm for figuring out the 100th digit of Pi.
* There’s an algorithm for figuring out your monthly mortgage payment given the purchase price and interest rate.
* There’s an algorithm for comparing one file against another on your computer.

*Typically*, the term “algorithm” is used when talking about steps taken in mathematics or computers.

Let’s say that I gave you a shuffled stack of cards with a bunch of different people’s names on them, and told you to put them in alphabetical order. How would you do it?

Well, there’s a few ways. You could start laying the cards out in a line, roughly where you expect them to be in the alphabet. Then add cards on either side of the ones you already put down, depending on the letter. Or maybe you could flip through all the cards, pull out all of the A names, then go back through and do it again for all the B names…

Some of these ways will be faster than others. But you could write your way down as a set of simple instructions that anyone else could follow with their own set of names to sort. That set of instructions — the process by which you sort the cards — is an algorithm.

Remember, that computers are very, very stupid. They are very good at following very precise instructions, but they are not good at thinking on their own. If you want a computer to sort names in alphabetical order, you need to tell them exactly how to do it. Some of those ways will be super fast, where other ways might take the computer a while.

Computer scientists like to come up with many different clever ways of doing things like sorting names. The actual code, or which computer coding language you use to actually write the algorithm, isn’t as important as making sure the algorithm is efficient and well designed. If you have millions of names to sort, the right algorithm might be hundreds of times faster than a slower one.

When Facebook had to write it’s “news feed“ feature, someone needed to design the specific set of instructions and criteria that determine which posts get put into your feed. These rules are an algorithm. These days in pop culture, it’s just called “the algorithm“ because the exact set of rules are secret, and Facebook won’t tell you exactly what they are.