We often think of artificial intelligence as something futuristic or hidden inside high-tech labs. In reality, algorithms—the step-by-step procedures that solve problems—are woven into almost every digital tool we use, from voice assistants to smart thermostats. But what exactly is an algorithm, and why are they so crucial to AI?
The word “algorithm” comes from the name of the Persian mathematician Al-Khwarizmi, whose works introduced systematic problem-solving methods to Europe in the 9th century.
An algorithm is a procedure that consists of a sequence of operations. Usually, a computer manages these operations by either finding the correct solution to a problem in a finite time or telling you that no solution exists. Even though people have solved algorithms manually for literally thousands of years, doing so can consume huge amounts of time and require many numeric computations, depending on the complexity of the problem to be solved. Algorithms are all about finding solutions, and the speedier and easier, the better. Algorithms have become hard-coded into the intelligence of humans who devised them, and any machine operating on algorithms cannot but reflect the intelligence embedded into such algorithmic procedures. AI provides the means to simulate the human in processing and solving existing algorithms, but currently, AI can’t replace humans or mimic human creativity in devising new algorithms.
Think about a tool or app you use daily. Can you identify an algorithm it relies on? What problem does that algorithm solve for you?
People tend to recognize AI when a tool presents a novel approach and interacts with the user in a human-like way. Examples include digital assistants such as Alexa, Cortana, Google Assistant, and Siri. However, certain other common tools, such as GPS routers and specialized planners (like those used to avoid automotive collisions, autopilot airplanes, and arrange production plans) don’t even look like AI because they’re too common and taken for granted as they act behind the scenes. In addition, it’s important to consider alternative forms of AI, such as smart thermostats that control the environment based on past usage and current environmental data, and smart garage door openers that automatically detect when you accidentally leave the door open after you leave for work.
Only tools that talk to us or act “human-like” are powered by AI algorithms.
Many AI algorithms operate behind the scenes in everyday technology, from GPS routing to smart home devices, even if their intelligence isn’t obvious to us.
Every time you ask your GPS app for the fastest way home, it uses algorithms to search through millions of possible routes and pick the best one for your conditions—often without you even realizing it.
The tendency for people to stop considering a technology “AI” once it becomes commonplace and its intelligence is taken for granted.
This is clearly the AI effect, as named and described by Pamela McCorduck, who wrote a notable history of AI, Machines Who Think, in 1979. The AI effect states that people soon forget about successful, intelligent computer programs, which become silent actors while attention shifts to AI problems that still require resolution. The importance of classic algorithms to AI gets overlooked, and people start fantasizing about AI created from esoteric technology, or they equate it with recent advances, such as machine learning and deep learning.
How does the “AI effect” shape your perception of what counts as “real” artificial intelligence?
Want to go deeper? The science behind “NP-complete” problems
NP-complete problems are a special class of computational problems for which no fast (polynomial-time) solution is known—and might not exist! These problems are so challenging that even the most powerful computers struggle to solve them quickly. Many AI challenges, like optimal planning or complex pattern recognition, fall into this category, which is why AI often uses heuristics or “good-enough” approximations rather than perfect answers.
Examining what an algorithm does
An algorithm always presents a series of steps, but it doesn’t necessarily perform all these steps to solve a problem. (Some steps are optional or performed only under specific conditions.) A group of related steps is an operation, such as the tea-making operation being composed of these steps:
- Pour water into the teapot.
- Turn on the fire to heat the water in the teapot.
- When water is heated, pour it into the cup.
- Place a teabag in the cup and steep the tea for the recommended time.
- Remove the teabag.
- (Optional) Add sugar to the tea.
- (Optional) Add milk to the tea.
- Drink the tea.
- (Optional) Toss the tea in the sink when it becomes undrinkable.
The scope of algorithms is incredibly large. Operations may involve storing data, exploring it, and ordering or arranging it into data structures. You can find algorithms that solve problems in science, medicine, finance, industrial production and supply, and communication.
All algorithms contain sequences of operations to find the correct solution to a problem in a reasonable time (or report back if no solution is found). A subclass of algorithms, heuristics, produce good, but not necessarily perfect, solutions when time-to-solution is more critical than finding the perfect solution. AI algorithms distinguish themselves from generic algorithms by solving problems whose resolution is considered typically (or even exclusively) the product of human intelligent behavior. AI algorithms tend to deal with complex problems, which are often part of the NP-complete class of problems (where NP is nondeterministic polynomial time) that humans routinely deal with by mixing a rational approach with intuition.
In the tech industry, AI algorithms are behind everything from supply chain optimization to pattern recognition in healthcare diagnostics. These solutions often start with classic algorithms, then use AI to handle the messy, real-world variables.
A rule-of-thumb or shortcut algorithm that finds a good-enough solution quickly, especially when an exact solution is too costly or slow to compute.
Here are just a few examples:
- Scheduling problems and allocating scarce resources
- Searching routes in complex physical or figurative spaces
- Recognizing patterns in image vision (versus something like image restoration or image processing) or sound perception
- Processing language (both text understanding and language translation)
- Playing (and winning) competitive games
NP-complete problems distinguish themselves from other algorithmic problems because finding a solution for them in a reasonable time frame isn’t yet possible. NP-complete isn’t the kind of problem you solve by trying all possible combinations or possibilities. Even if you had computers more powerful than those that exist today, a search for the solution would last almost forever. In a similar fashion, in AI, this kind of problem is called AI-complete.
Why do you think AI relies on heuristics for certain problems instead of always searching for the perfect solution?
- You can define what an algorithm is and describe its key role in AI.
- You can give examples of algorithms operating both visibly and behind the scenes.
- You understand why some AI problems are so challenging that perfect solutions are nearly impossible to compute.
Planning and branching: Trees and nodes
Planning helps you determine the sequence of actions to perform to achieve a certain goal. Deciding on the plan is a classic AI problem, and you can find examples of planning in industrial production, resource allocation, and robot motion. Starting from the present state, an AI first determines all possible actions from that state. Technically, it expands the current state into a number of future states. Then it expands all future states into their own future states, and so on. When you can no longer expand the states and the AI stops the expansion, the AI has created a state space, which is composed of whatever could happen in the future. An AI can take advantage of a state space not just as a prediction (actually, it predicts everything, though some future states are more likely than others) but also because AI can use that state space to explore decisions it can make to reach its goal in the best way. This process is known as the state-space search.
Working with a state space requires the use of both particular data structures and algorithms. The core data structures commonly used are trees and graphs. The favored algorithms used to efficiently explore graphs include breadth-first search and depth-first search.
Building a tree works in much the same way that a tree grows in the physical world. Each item you add to the tree is a node. Nodes connect to each other using links. The combination of nodes and links forms a structure that looks like a tree.
Trees have a single root node, just like a physical tree. The root node is the starting point for the processing you perform. Connected to the root are either branches or leaves. A leaf node is an ending point for the tree. Branch nodes support either other branches or leaves. The type of tree shown is a binary tree because each node has, at most, two connections (but trees remain useful even when the structure varies).
Write out the steps you follow to prepare a cup of tea, coffee, or any simple task. Then, identify which steps are always required and which are optional. (Hint: Try matching your list with the tea-making algorithm above!)
- List out each step in your chosen process.
- Highlight the steps that are optional.
- Circle any steps where a decision or condition is involved.
- Share your sequence with a peer and compare your algorithms.
Describe a situation in your life or field where using a heuristic (quick solution) is more practical than searching for a perfect answer. Why is “good enough” sometimes better than “perfect”?
Algorithms are all about finding solutions, and the speedier and easier, the better.
What is an algorithm?
Tap to revealA procedure consisting of a sequence of operations designed to solve a specific problem or complete a task.
What is a heuristic?
Tap to revealA rule-of-thumb algorithm that produces a good-enough solution quickly, especially when perfect solutions are impractical.
What is the AI effect?
Tap to revealThe phenomenon where once an AI successfully solves a problem, people stop considering it “real” AI because it has become routine.
Which of the following best describes an NP-complete problem?
Algorithms are the foundation of both traditional and artificial intelligence, powering solutions to problems in ways that reflect both human ingenuity and the limits of computational power.
Heuristics enable AI to tackle complex or unsolvable problems by delivering practical, good-enough solutions when perfect answers are impossible or impractical to find.
How do you think the “AI effect” influences public understanding of what AI can—and cannot—do?