seegongsik
Saved words
Algorithms

Solving a problem in a set order

Algorithm isn't a hard word. It's "a set order for solving a problem." Like cooking noodles, or finding a route. Once the order is set, anyone gets the same answer.

01

The order for making a sandwich

Say you're making a sandwich.
Take out the bread,
spread the jam,
cover it with bread.
Walk through this set order
one step at a time,
and the sandwich is done.
This is an algorithm.

1Take out two slices of bread
2Spread jam on one
3Cover with the other slice
4Cut it in half
Done! The sandwich is ready
Press one step at a time. Walk the order and the problem gets solved.

A set order, one step at a time. (Take bread โ†’ spread jam โ†’ cover โ†’ cut โ†’ done)

The "algorithm" that sounded hard
is really just this.
"What to do first,
and what to do next"
an order, set in advance.
A recipe, an assembly guide,
they're all algorithms too.

02

Socks first, or shoes first?

The order isn't there for nothing.
Put on socks, then shoes,
and it works fine.
But put shoes on first,
then try the socks?
It won't work.
If the order is wrong,
the result is wrong.

1Put on socks
2Put on shoes
Dressed just right
Even the same two steps: change the order and the result changes.

Try changing the order. (Right order โ†’ works ยท reversed order โ†’ doesn't)

So in an algorithm
the order really matters.
What you do first
can make it work
or not work.
It's not just knowing the steps,
but knowing the right order.

03

Same order, same result

Here's the power of a set order.
If I follow that order,
and a friend follows that order,
we both get the same answer.
It doesn't sway with mood or luck.
As long as the order is the same,
the result is the same.

Me
3 plus 4
= adding in order
?
Friend
3 plus 4
= adding in order
?
Follow the same order and anyone gets the same answer. That is the power of an algorithm.

Follow the same order, both get the same answer. (Me โ†’ 7 ยท friend โ†’ 7)

Why is that good?
Because you can trust it.
"Follow this order
and you'll surely get this answer."
So if you write this order
for a computer too,
it'll always do the same thing.

04

Finding the bigger of two numbers

Let's follow one truly small algorithm.
Finding the bigger of two numbers.
"Compare the two,
pick the bigger one."
That order is all it takes.
Put in the input, out comes the answer.

Number A
7
Number B
4
1. Look at the two numbers A and B (7, 4)
2. Compare whether A is bigger than B (7 > 4?)
3. Pick the bigger side
Press the button to solve in order
Walk the set order, and from the input (7, 4) comes the answer (7).

Input โ†’ order โ†’ answer. (Number A 7 ยท number B 4 โ†’ compare โ†’ answer 7)

Seems like nothing, right?
But small orders like this,
gathered and gathered,
do amazing things.
Lining up thousands,
finding just what you want.
All the power of a "set order."

05

To make a computer do it

A computer can't
figure things out "on its own."
What to do, in what order,
we have to write it down.
That order is exactly an algorithm.
Write it well,
and a computer does it fast and exactly.

Algorithm = an order for solving problems
Set steps ยท the right order ยท the same answer for anyone. You have the basics.
Sorting
Lining up what is jumbled
Searching
Finding what you want
Beyond
Smarter orders
Next time we will touch "sorting," lining up jumbled things in order.

Once you know order, now. (Algorithm = an order for solving โ†’ sorting ยท searching ยท beyond)

From now on, whatever algorithm you see,
don't be scared.
However complex it looks,
inside it's the same.
"What to do first,
and what to do next"
just an order, set in advance.

In one lineAn algorithm is "a set order for solving a problem." Walk the steps and an answer comes out; if the order is wrong, the result is wrong. With the same order, anyone gets the same answer. So write a computer an order, and it always does the same thing.
Was this helpful? Support seegongsik
โ† Algorithms