We know Facebook, Google, and Amazon have algorithms that give us updates, search results, and product recommendations, but what does that actually mean? What is an Algorithm? Can you write one? What would it look like if you did? Since they run so many aspects of our daily lives, it's important to have a basic idea of exactly what's going on under the hood – and it really isn't as daunting as it often seems. P> ContentsInformal definition:algorithms are just recipesMore formally:algorithms are clear and unambiguous formulasEveryday algorithmsEverything is an algorithm
At its core, an algorithm is simply a well-defined set of steps that you can follow, usually taking a few inputs and producing a different set of outputs. A cupcake recipe can be an algorithm. The same goes for directions to a friend's house, reading sheet music, or the process of looking up a word in a dictionary. Raymond Queneau even printed a book of ten sonnets with verses that can be seamlessly mixed and matched to create 100,000,000,000 original poems. How these algorithms are implemented varies widely, but you don't need to know any programming languages to understand the basic logic behind them. For example, the following is an algorithm for giving simple walking directions.
One algorithm you probably use every day is Google's PageRank algorithm, which looks at hundreds of factors about a web page, runs them through its formula, and assigns it a score. The search results you see in response to your search term are a direct result of this score. It works so well because it follows a set of clearly defined rules that tell it what to look for, what to ignore, and what to do with the information it finds.
To visualize a very simple search process, here is a linear search algorithm that searches for the number 3 in a list of numbers.
list =[1, 3, 5]
After these steps, the computer will look at the first number, which is one. Since it is not equal to three, it goes on and checks the next number. Since this number is three, it returns something like "Number three is the second item in the list".
In Python code, a linear sorting algorithm would look like the following image.
All the code does is take a list of numbers, look at each item in the list, and check if it matches the search term. If nothing happens, it just returns "False". It's an extremely simple algorithm, but whether it's one line of code or a million, every existing algorithm works on the same basic principle:take information, process it according to some logic. preset and get results.
Most of the algorithms that run our daily lives are not open source. We don't know exactly how Google determines which search results to display or how Facebook aggregates your News Feed, but we can still see the results of those calculations. Nonetheless, they are important, and we have a pretty good idea of the basic logic behind them.
Once you know what an algorithm looks like, you can't stop noticing them. They are not just in our technology, because, after all, they are in our brains. Everything we do is the result of receiving input, processing it, and producing output. Most of these processes are stored in a constantly rearranging black box, but they are there, behind the scenes, to help us move around, understand language, and make decisions about things. Humans are equipped to understand algorithms on an instinctual level, so even though computer algorithms are written in indecipherable math and code, they can all be translated into terms we understand.
Image Credit:Mandelbrot Game Image, Websites Interconnected to Illustrate PageRank, CTP TheoryOfComputation Linear Search, Shell Sorting Algorithm Color Bars