# Understanding the Basic Algorithms that Power Your Digital Life

Last Updated: March 26, 2016 12:51 am
Understanding the Basic Algorithms that Power Your Digital Life

This is Part 2 of a series on algorithms. Part 1, How to Explain Algorithms to Kids, is available here.

# Understanding the Basic Algorithms that Power Your Digital Life

Algorithms provide a series of instructions that the computer follows to arrive at an answer and they underlie all of our technology. The problem that the algorithm is solving might be sorting a list, compressing a file, or determining which Internet pages are most relevant to you when you search for something. Algorithms determine how traffic signals are scheduled, how postal services can most efficiently deliver your mail, and much more.

In the digital age, kids should do more than just use technology. They need to explore the algorithms that power their phones, their social media sites, and their worlds so they can become fluent in coding, the language of technology, and take an active role in the creation of technology.

## Search and Recommendation Algorithms

When you type a search into Google, it uses a very sophisticated algorithm that determines which pages on the internet are relevant to your search and ranks them based on how relevant and reputable they are. At its core, the PageRank algorithm takes into account how many other sites link to a given web page as well as the rank of the linking sites in order to determine the rank of that page. And it returns your results in less than a second!

The algorithm that recommends connections on social media (like the “People You May Know” recommendations on Facebook or Linkedin) works by calculating your degrees of separation from other users. If you are friends with Amy and Amy is friends with Ben, Facebook assumes that you might know Ben as well and recommends him as a potential connection. But if Amy is friends with Ben and Ben is friends with Charlene and Charlene is friends with Daryl and Daryl is friends with Erin, Facebook is unlikely to recommend Erin as a connection. In fact, scientists have theorized that, because of how globally connected we all are, there are only six degrees of separation between any two people on earth!

And when you use Amazon or Netflix, they recommend purchases or other shows you might be interested in based on a collaborative filtering algorithm that tries to predict what users will like based on the choices of other users with similar taste profiles.

## Sort Algorithms

You may not think about it when you are sorting things in real life, but you are following an algorithm! Computers need to sort lists with millions of values extremely quickly, so sorting algorithms are very important.

Can you describe how you might sort ten books into alphabetical order? If you had to tell someone who didn’t understand the process of sorting how to sort the books, what steps would you write out?

You might start with one book, then add one book at a time, placing it in the proper place in your lineup. But imagine how many hours or years this would take if you had to do this with hundreds, thousands, or even millions of books! This algorithm is called Insertion Sort, and it works fine for small lists, but takes a lot of time for longer lists.

Another way you could sort the ten books would be to arrange them in a random order, then go down the list comparing books that are next to each other. First you would compare the first and second books. If they are in the wrong order, you swap them. Then you compare the second and third books, and again decide whether to swap them. Whenever you reach the end of the list, you go back through the list again, each time only comparing books that are immediately next to each other. This is called the Bubble Sort Algorithm, and it is again reasonable for small lists, but very inefficient for longer lists.

This project shows one way to implement a Bubble sort, with items in the list swapping to sort themselves:

Explore This Algorithm