Algorithm

It is like a step-by-step cooking recipe designed to ensure a dish turns out right every single time.

Definition A clear, ordered set of rules and instructions used to solve a specific problem or achieve a set goal. Because computers lack human flexibility and intuition, they need explicit, step-by-step instructions from start to finish to get the job done accurately.

Cooking Ramen and Algorithms

When you make instant ramen, you follow a specific set of steps: pour about 2 cups of water into a pot, bring it to a boil, add the noodles and seasoning packet, simmer for 4 minutes, and turn off the heat. This step-by-step procedure followed to achieve a specific result is called an algorithm.

Giving instructions to a computer works the exact same way. Computers cannot understand vague requests like 'make me something tasty with just the right amount of water.' Instead, they require crystal-clear, step-by-step rules like 'pour 550 ml of water' or 'add the noodles once the temperature reaches 100Β°C.'

If even a single step is out of order or missing, a computer will freeze or produce unexpected errors. Breaking down a complex problem into tiny, manageable steps with seamless logic is the core foundation of designing algorithms.

Algorithm via Ramen Cooking Steps Pour 550ml H2O No (Wait) Boiling? Add Ramen/Soup Boil 4m 30s Ramen Done

Different Approaches, Vastly Different Speeds

Imagine looking up a word in a thick dictionary. You could flip through every single page from front to back until you find it. Alternatively, you could open the dictionary right in the middle, check whether your word comes before or after that point, and cut your search area in half with every flip.

Both methods eventually lead you to the right word. However, the difference in time and effort is massive. If a dictionary has 100,000 words, flipping page by page (linear search) could take up to 100,000 checks. Cutting the search space in half (binary search) takes only about 17 checks.

This is why software engineers work tirelessly to design better algorithms. Depending on which algorithm you choose, the exact same task could finish in 0.01 secondsβ€”or leave a computer frozen for days.

Comparison: Linear vs Binary Search Linear Search: Check one by one Need 77 checks 1 2 3 76 77 100 Binary Search: Halve the range Found in 7 steps! 1 100 50 β‘  Check 50 75 β‘‘ Check 75 77 β‘’ Found 77!

To Be More Precise

To be more precise, computer science requires an algorithm to meet a few strict criteria. It must produce a definite output for a given input, and every step must be unambiguous and clear. Each instruction must be feasible to execute, and the process must eventually finish rather than running forever in an infinite loopβ€”a property known as 'finiteness.'

Today, the video recommendations on YouTube and Netflix, as well as the real-time fastest routes on Google Maps or Apple Maps, are all powered by sophisticated algorithms. They analyze your watch history and viewing habits to pick the content you will love most, or calculate live traffic across thousands of roads to find the fastest way home.

Ultimately, an algorithm is not just lines of computer code. It is a method of thinking that breaks down complex, messy real-world problems into simple, logical steps.

πŸ€” Common misconceptions

βœ• Myth

Algorithms are cutting-edge tools used only in AI and computer programming.

βœ“ Fact

Algorithms are logical procedures that existed long before computers were invented. Origami instructions, cooking recipes, and basic arithmetic like long division are all everyday examples of algorithms.

🧺 Where you meet it

1 Navigation apps calculating the fastest detour around heavy traffic in real time
2 Binary search quickly finding a name in an alphabetized list by cutting the remaining pages in half each step
πŸ’‘ In one sentence

An algorithm is a clear, step-by-step set of rules and instructions designed to solve a problem or complete a task.