AI Basics Beginner

Algorithm

A fixed sequence and set of rules for solving a problem

Key points
  • An algorithm is a fixed sequence for solving a problem. What to do first, and what to do under which condition, is spelled out with nothing left blank.
  • The same problem can have several different algorithms. You choose based on which one is faster and less costly to run.
  • An algorithm isn't magic. A person sets the procedure, and the computer just follows it exactly.
  • In AI, algorithm means the training method. What that method produces is the model — the two are different things.
  • "The YouTube algorithm" you hear about in the news isn't one procedure — it's shorthand for a whole tangle of procedures and models working together.
Contents

1The analogy

The back of a ramen packet has cooking instructions printed on it. Pour in a set amount of water, add the noodles and seasoning once it boils, simmer a few more minutes, then turn off the heat. The order and conditions are spelled out completely, so anyone who follows it gets roughly the same bowl of noodles. A written procedure like this is an algorithm.

The recipe is not the noodles. No matter how long you stare at the words on the back of the packet, you don't get full. You actually have to carry out the steps before noodles appear in the pot. The procedure and the result live in different places.

And there's more than one way to cook the same noodles. Boil the water first, or put the noodles in with the water from the start, or use a microwave. The result is similar, but the time it takes and the dishes it leaves behind are not.

2In detail

It's built from steps and conditions

Two things belong in every algorithm: an order — what to do in which sequence — and a condition — what happens, and when, that changes the path. In "once it boils, add the noodles," the first half is the condition and the second half is the action.

Leave a gap and it stops being a procedure. "Season it to taste" works fine for a person, but a computer has no way to know how much of what to add. Writing an algorithm means filling in every one of those vague spots, with nothing left over.

It also needs a defined stopping point. A procedure that repeats the same step needs to say when to quit, or it becomes a loop that never ends.

Changing the order changes the result

The same ingredients give different results depending on order — whether the seasoning goes in before or after the water boils changes the taste. In an algorithm, order isn't decoration; it's the core of the procedure.

The same holds for what a computer does. Filtering data and then sorting it can take a very different amount of time than sorting first and then filtering. Even when the final result is identical, one order can finish in seconds while the other takes hours.

The same problem has more than one solution

Take a list of names and ages that needs sorting alphabetically. You could scan through from start to finish, swapping entries as you go, or split the list in half, sort each half, and merge them back together. Both land on the same sorted list, but as the list grows longer, the time gap between the two methods stretches enormously.

That's why choosing an algorithm isn't only about the result — it's about how long it takes and how much room it needs. A short list favors the simple method; a very long one favors the faster, more complicated one. The right answer depends on the situation.

In AI, algorithm means the training method

In machine learning, algorithm means the procedure for how to adjust the numbers inside a model, based on the data. Measure how far off it is, decide which direction and by how much to adjust, adjust, and measure again — the same fixed rule, repeated.

What's left once that procedure finishes is a result with the numbers settled into place. That's the model. A recipe isn't the noodles, and a training algorithm isn't the model, either. The algorithm is what a person writes down in advance; the model is what comes out of applying that procedure to data.

Which is why the same algorithm produces a completely different model depending on what data you feed it, the same way the same recipe produces a different dish depending on what ingredients go in.

"The algorithm" in the news means something broader

When someone says "the algorithm put this video in front of me," they don't mean a single procedure. It's shorthand for several stages of deciding what to show, a handful of trained models, and rules the company running the service set on top of all of it.

The word sounds mysterious because none of that is visible from outside. Nobody outside can tell what standard was used to pick something, and often the people who built it can't fully explain the result either — which is exactly why arguments break out over why a recommendation turned out the way it did.

3More precisely

An algorithm is a procedure that takes an input, runs it through a finite number of defined steps, and produces an output. For any input it must eventually finish, and each step has to be unambiguous — those two properties are what earn it the name. Algorithms that solve the same problem get compared by how steeply their running time climbs as the amount of data grows. One procedure whose time only doubles when the data doubles, and another whose time quadruples, end up worlds apart once the data gets large.

The analogy breaks down in one place. A ramen recipe survives a person eyeballing the steps and bending them slightly — the result doesn't change much. A computer follows exactly what's written, so getting a single step wrong throws off the whole result. And plenty of training algorithms don't produce the same result twice. Starting numbers get picked at random, or the order data gets shuffled changes run to run, so the same procedure on the same data can turn out a slightly different model each time. That's one reason two teams can follow what looks like the same published method and still end up with models that don't perform identically.

4Try it yourself

5Common misconceptions

  • It's easy to think algorithm and model mean the same thing, but actually the algorithm is the training procedure, and the model is what you get after applying that procedure to data.

  • It's easy to think an algorithm makes judgment calls on its own, but actually it just follows a procedure a person already set — the person's choices are already baked into it.

  • It's easy to think AI is something other than an algorithm, but actually the procedure for looking at data and adjusting numbers is exactly what sits at the core of AI training.

7One-line summary

In shortAn algorithm is a fixed sequence and set of rules for solving a problem, and in AI it refers to the very procedure that looks at data and builds a model out of it.

Spotted an error or have a better analogy? Suggest an edit · Last updated2026-09-02