 # Definition

An algorithm is a precise sequence of operations commonly used to solve a problem or calculate something. They are a step-by-step path that links a mathematical problem to its solution. It can describe anything from a cookbook recipe to computer programming.

Algorithms take an input and make an output:

• Cooking from a recipe creates a dish.
• Using a step-by-step app, complete taxes each year.
• Tying shoelaces in a specific order keep shoes on during the day.

An algorithm often stops after a discrete function is completed, calculated, or processed.

# Why Use It

Algorithms solve problems in a repeatable manner and produce a known outcome:

• By assessing and developing a step-by-step solution, you can implement a process that delivers a similar result each time.
• As a result of automation and guided instruction, a system can scale with the need or demand.
• They can automatically make decisions by executing logic and math.
If they are executed correctly, it produces a guaranteed result.

Algorithms can be simple or complicated depending on the problem:

• A traffic light on a street simply times cars’ movement to ensure they move continually.
• In contrast, a complex computer program can analyze a photo to understand the picture’s people, places, or things.

# When to Use It

Algorithms are in nearly all aspects of life: systems need them to function. These instructions solve problems and adapt to their inputs. They don’t aim for perfection but rather to produce valuable outputs. Nearly every field has problems that require algorithms, and when they’re similar, the same algorithm can be used for multiple purposes.

There are numerous algorithms. A few kinds are:

• Search algorithms
• Machine learning algorithms
• String algorithms
• Sorting algorithms
• Merge algorithms
• Combinatorial algorithms

Amongst their many uses, they can be found in surprising places:

• A GPS tracker
• A Constitution or Bill of Rights
• Bees looking for honey
• A Cooking recipe
• And biological neural networks

As a conduit for completing a task to spec or automating a process entirely, algorithms are increasingly valuable to humanity.

# How to Use It

Algorithms come in various formats: natural language, flowcharts, and programming, among others. Natural language algorithms are usually less complex when compared to more unambiguous flowcharts. Programming languages are often created for computer use but can document an algorithm.

An algorithm contains the following:

• Unambiguous steps that are clear and easy to follow.
• Inputs that are defined and in a specific order of operations.
• Known outputs that are consistently reproducible.
• A finite process that ends at some point.
• It’s feasible to execute with the available resources.
• It’s language agnostic, and the instructions are translatable.
• It’s resource-efficient regarding space (information storage), time to complete, and can handle multiple inputs.

To develop an algorithm, you will need to:

• Define the problem you’re attempting to solve.
• Develop a model that defines your concept.
• Design the algorithm from start to finish.
• Test the outcome to ensure it is both expected and repeatable.
• Analyze, iterate, and improve the solution.

Design with Turing machine descriptions:

• High-level description: Use words to describe an algorithm without much detail.
• Implementation description: Note how the algorithm will store information or data.
• Formal description: A highly detailed description of how it works and its different states.

There are classifications of algorithms that help break down their best uses.

One way to classify algorithms is by their implementation:

• Recursive algorithms invoke themselves repeatedly until a termination condition is met.
• Deterministic algorithms solve problems with an exact decision at each step. Conversely, Non-deterministic algorithms solve problems by guessing—using heuristics to fine-tune them.
• Serial algorithms execute one instruction at a time. Parallel algorithms employ several processors to work on a problem all at once. Distributed algorithms utilize several machines connected to the same network.
• Logical algorithms contain controlled logical deduction and are defined as Algorithm = logic + control. The logic part is axioms for computation, and the control part specifies how deductions are used.
• Exact solutions seek one true answer, whereas Approximation algorithms attempt to get close to the truth.
• Quantum algorithms use a vital feature of quantum computing, such as entanglement or superposition.

Another way to classify algorithms is by design methodology or paradigm:

• Brute-force search is where you try every possible solution to determine the best.
• Divide and conquer algorithms divide the problem into smaller ones, usually recursively, to solve them quickly.
• Randomized algorithms make random choices, which can be helpful for approximate solutions.
• Graph exploration algorithms note specific rules for navigating a graph.
• Reducing complexity is an approach that swaps a complex problem with a known one.
• Backtracking is a technique where multiple solutions are built at once.

Optimization problems require a different approach:

• Linear programming solves linear functions bound to linear equality and inequality constraints. These constraints produce optimal solutions.
• Dynamic programming examines substructures and surfaces subproblems that sometimes overlap one another. Instead of solving every subproblem, the algorithm caches an answer and recalls it when necessary. By doing so, one finds the optimal solution faster and more efficiently.
• Heuristic algorithms are valuable when an optimal solution is impractical. Over time and repetition, these algorithms arrive closer to an optimal solution and, if run infinitely, would find a perfect solution. Instead, these algorithms usually terminate quickly and deliver the best answer in the shortest time possible.
• The greedy algorithm examines the substructures of a given solution. The algorithm then seeks to improve on the solution by making modifications to how it is constructed. Some algorithms solve for local maxima while others search for a global maximum.

Amount of time is another way to classify algorithms:

• Linear time is when run time is proportional to the input size.
• Constant time is when the run time is identical regardless of the input size.
• Logarithmic time is when the number of operations increases slowly as the input size increases.
• Polynomial time is when run time is a power of the input size.
• Exponential time is when run time is an exponential function of the input size.

An algorithm must be efficient to be acceptable and can be tested in two phases:

• Priori Analysis is where one reviews an algorithm as a written document before implementation. This type of analysis determines the algorithm’s complexity.
• Posterior Analysis is where one reviews an algorithm after its implementation. This type of analysis determines the space required for storage, time efficiency, and the quality of its outcomes.

# How to Misuse It

Not everything needs to be an algorithm. They can take a long time to write and test. Complex logic is hard to understand and translate. Branching and looping statements are tough to comprehend.

# Next Step

Algorithms are everywhere and affect our lives in almost every way. We are constantly using them to complete discrete tasks and are being used by them for a variety of outputs.

Building an algorithm does not require coding experience but rather a way to codify a set of inputs, processes, and repeatable outcomes.

So, don’t put off creating a repeatable process. First, determine what you want to accomplish. Review all available data, historical and current. Choose the models which fit best with the approach. Test your algorithm rigorously to ensure inputs and outputs are correct. Continue running it and fine-tune the algorithm.

After you have had a chance to build one, then review its efficacy and make updates if necessary.

# Where it Came From

Babylonian mathematics is where the first known algorithm was uncovered. Sumerian tablets from 2500 BC host the earliest division algorithm. From 1800-1600 BC, Babylonian tablets contained the first computing formulas to calculate astronomical events. Egyptian arithmetic algorithms date back to 1550 BC. The Euclidean algorithm was published in Euclid’s Elements in 300 BC and is still in use today. In 240 BC, Greek mathematicians used algorithms to find prime numbers.

The term algorithm came from the Persian mathematician Muḥammad ibn Mūsā al-Khwārizmī whose term was translated into Latin as Algoritmi in ~780. It was first used in English around 1230, although the modern algorithm interpretation is from the 19th century. In 1928, David Hilbert posed the Decision Problem, and the concept of algorithms attempted to solve it. Several years later, Gödel–Herbrand–Kleene formalized algorithms further with recursive functions. Then in 1936, Alan Turing developed the Turing machine, which can implement any computer algorithm.

# What Are Mental Models?

Mental models are thinking tools that help guide and shape our perceptions of the world. They simplify complexity so we can understand life better, make decisions confidently, and solve problems. ## Deep Dive Into Mental Models

Mental models are thinking tools. They simplify complexity so you can solve problems and make decisions more confidently. Sound interesting? Get my newsletter.

As a thank you, I'll send my ebook The Independent Creative's Guide to Personal Branding. ## Download The Independent Creative's Guide to Personal Branding — It's Free! 