Problem-Solving With Algorithms



Algorithms are used by both computers and humans to make interconnected decisions throughout our world. Google's search algorithm sorts through billions of webpages, presenting desired information to you in milliseconds. GPS systems manage massive systems of transport, ride sharing, and shipping. Algorithmic trading executes high-speed decisions to determine optimal investments faster than any human. While these algorithms may sound intimidating, all algorithms are essentially detailed sets of instructions that computers follow to arrive at an answer. Humans also constantly utilize (simpler) algorithms: for example, a recipe to make dinner is an algorithm.


For kids, understanding the process of building an algorithm helps them build a strong foundation in logical thinking and problem solving. Algorithmic thinking in kids develops the cross-disciplinary skills to generate creative, original solutions to a wide array of problems in STEM and beyond. In this article, we'll walk through an example of an algorithm and real-world uses of algorithms across multiple fields.


Historical origins of algorithms


The term algorithm comes from 9th century Persian mathematician and geographer Muhammad ibn Musa al-Khwarizmi. The term algorithm was derived from the Latinization of his name to "Algoirtmi" when his book On the Calculations with Hindu Numerals was spread into Europe and translated into Latin as Algoritmi de numero Indorum. This book was critical to the development and utilization of the decimal system we use today. Al-Khwarizmi developed a systematic approach to solving linear and quadratic equations, which was then termed algebra. This algorithmic approach established the basis for modern mathematics.

In 1936, Alan Turing defined a foundational concept for computer scientists in his paper on the Turing machine. He illustrated that problems could be broken down and solved by machines executing algorithms to perform operations.


What is an algorithm?


An algorithm is a detailed, step-by-step process followed in order to accomplish a specific task or to solve a specific problem.

Computer algorithms can appear complex, but the underlying concept is approachable for both adults and kids. We can define an algorithm by writing out the step-by-step instructions, thinking about things in terms of discrete steps. For example, our algorithm for a child's morning routine could be the following:

  1. Wake up and turn off alarm

  2. Get dressed

  3. Brush teeth

  4. Eat breakfast

  5. Go to school


How do algorithms shape our world?


Google's PageRank algorithm determines how pages on the internet are displayed and ranked based on their relevance to your search. In less than a second, interrelated search algorithms process information extremely quickly, interpreting your query and returning personalized results.


Sites such as Amazon and Netflix base recommendations on collaborative filtering algorithms that look at other uses with similar interests and tastes and subsequently deliver predictions for purchases and shows.


Sorting information into logical order for better presentation and easier analysis is a fundamental consideration for interfaces and databases. Thus, efficient sorting of data is a very common algorithmic challenge. For a visual explanation of various sorting algorithms, this video presents 15 Sorting Algorithms in 6 Minutes, including merge sort and quick sort.

Mapping applications such as Google Maps need to calculate routes through cities, taking into account distance, traffic, and accidents. Tools such as Google Flights consider also routes through many airports while considering layovers, prices, and time. Next, we'll look at Dijkstra's algorithm, an algorithm that helps us find these optimal paths.


Shortest Path: Dijkstra's Algorithm


Consider the process of flying from New York City to San Francisco. There are a large number of different routes to get there: some are direct flights, but some have multiple stops. If we want to calculate the shortest way to get from New York City to San Francisco, we can look at a map with each city represented as a dot with routes between them. We could attach cost, distance, and time to each of these routes. That way, we could more easily weigh our options.

For example, we could fly from New York to Atlanta, and then from Atlanta to San Francisco, which would likely increase the cost, distance, and time required. If we want to figure out what the optimal path is for our specifications, we can create a graph that represents all of these interconnected cities. These cities are represented by nodes, and their connections (edges) are labeled with weights that represent the cost, distance, and time data we want to consider. These nodes and edges are represented by a graph.


How do we use this weighted graph that represents the 1,200 international airports and the flights between them? Dijkstra's algorithm is a famous pathfinding algorithm that determines the shortest path between weighted nodes in a graph. Dijkstra first came up with the algorithm as a "twenty-minute invention" in 1956 while considering what the shortest way to travel from Rotterdam to Groningen was. The algorithm is approachable and makes sense even without the context of computer programming.


Let's go back to our previous example and say that all the direct flights are sold out, so now we have to find a route with multiple stops, and w