**The Importance of Algorithms for Kids**

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:

- Wake up and turn off the alarm
- Get dressed
- Brush teeth
- Eat breakfast
- 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 a logical order for better presentation and easier analysis is a fundamental consideration for interfaces and databases. Thus, the 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 quicksort.

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 we are purely optimizing for price. Beginning from New York City, we examine the nodes (airports) that are connected - let's say the options are flying to Atlanta ($150) and Denver ($300). We mark each node with the cumulative price so far. Then, let's say from Atlanta, we can fly to Denver ($100) or San Francisco ($200). Now, Denver is labeled as $250 ($150 + $100) and San Francisco is labeled as $350 ($150 + 200). Finally, let's say we can fly from Denver to San Francisco for $150. This is not optimal, as we already have an option that will get us to San Francisco for $350. So, we have found that the cheapest route is New York City -> Atlanta -> San Francisco.

In reality, there would be many more route options to consider, but the process the algorithm follows remains the same. The idea is to start at the origin and follow each possible route and update the price at each city to the cheapest way we can get there, repeating until we've considered all the possible routes to get to the destination. We've purposely left out some details, but this is the big picture. In more formal terms, we might describe the algorithm this way:

To go from point A to point B, the algorithm begins from point A, then looks for the unvisited node with the lowest weight. From that node, it looks at all of the connecting nodes and considers those weights. If this makes routes cost less than before, then the distance to that node is updated. For example, if the previous weight from A to C was 10, but the distance from A to B is 3 and the distance from B to C is 4, then we can update the new cost of going from A to C as a total of 7. From there, the algorithm repeats the steps of traversing the lowest possible distance to the next unvisited node until the final point is reached, and the lowest total cost is determined.

Because the essential steps are not overly complicated, much of the work of repeated calculation and consideration is shifted to the computer. **That is the value of an algorithm, and why they are so useful in computer programming to break down tasks into chunks that can be solved through specific implementations.**

**Why are algorithms important for kids to learn?**

Even if we're not conscious of it, we use algorithms all the time. Learning how to create algorithms not only lays a strong foundation in programming skills, but is also useful for developing logical thinking skills beyond writing computer code. Being able to understand and implement an algorithm in code requires students to practice their structured thinking and reasoning abilities.

Here are some problems you can ask your child to discuss algorithmic solutions with you:

- How do we know if a number is odd or even?
- How do we calculate all of the factors of a number (i.e. the numbers that divide into it without remainder)?
- How can we tell if a number is prime?
- Given a list of 10 numbers in random order, how can we put them order?

If you'd like a hint to any of these, feel free to send us an email at **hello@learnwithjuni.com**!

**How can kids learn to program an algorithm?**

At Juni, all of our **online courses for kids** develop algorithmic thinking, for different ages. Through our private classes for **coding for kids**, our instructors are there to actively guide the student through learning new concepts, building their own projects, and solving problems in their code.

Throughout our courses, students are asked to consider problems like:

- In order for the player to win the game, what conditions have to be met?
- How can we keep track of the score in our game?
- How can we count the number of times each letter appears in a word?
- What are the steps we have to take to swap the smallest and largest numbers in a list of numbers?

In our advanced **Python Level 3** and **AP Computer Science A** courses, students learn about classic algorithms in computing like linear sort, bubble sort, merge sort, and binary search. Our **USACO Training Program** only accepts students who already demonstrate a high degree of independence with the fundamentals and basic data structures in Python or Java, and as students advance through the competition, they learn college-level problem-solving techniques and algorithms.

In general, **our students work through our structured curriculum at the pace appropriate to them**, focusing on building their fundamentals in one programming language at a time. They meet with their instructor weekly over videoconference, looking at a shared screen. The instructor takes time to review homework, to clarify questions and misunderstandings, to introduce new programming concepts, and to provide guidance and suggestions as the student is coding.

*This **article** originally appeared on **junilearning.com*