seegongsik
Saved words
Algorithms

Good enough instead of perfect

You saw it last time: for some problems the cases explode, so chasing the perfect answer to the end would take a lifetime. So do we give up? Not quite. Even if you can't get the perfect answer, a "good enough" one is often quick to find. You give up a little, and save a lot of time.

01

Set perfect aside for now

Here's a hard problem.
To find the perfect answer
you'd have to weigh every case,
and there are an enormous number.
Go all the way
and you'll surely get the very best.
But when
would that ever finish?
Press to count it out.

1
2
2
3
4
5
6
7
input size: 1 - cases to check: 2
Still countable for now.

Chase the perfect answer to the end. (Cases pile up and time explodes → no end in sight)

The number grows too fast.
Add just a few more
and there's many times as much to check.
So waiting for the perfect answer
all the way to the end
isn't realistic sometimes.
Still, we can't
just throw up our hands.

02

A good enough answer, fast

Here's an idea.
What if it doesn't have to be
the very best?
Instead of aiming for perfect,
just quickly
pull out a
"pretty good" answer.
Like we did with greedy,
picking the good thing
in front of us, briskly.

rough answer
instant
?
perfect answer
takes a while
?

A quick rough answer vs the perfect one. (The rough one comes instantly, the gap is small)

Look.
The rough answer popped out in a blink,
yet it's not far
from the perfect one.
A touch short,
but perfectly usable.
For many cases
this much is plenty.

03

It guarantees how good it is

But there's one worry.
Can we trust that
"pretty good" answer?
What if it's
secretly terrible?
So the clever methods
come with a promise.
They say, "this answer
won't be much worse
than the very best."

best
150
guarantee line (1.5x of best)

Guaranteed within 1.5x of the best. (Whatever answer comes, it stays inside this line, the worst is capped)

This is the truly neat part.
Draw a line like
"within 1.5x of the best,"
and however bad the answer,
it can't cross that line.
Not perfect,
but we know exactly
how far off it could be.
That's completely different
from a vague guess.

04

Trade accuracy for time

In the end it's a balance.
Spend more time
and the answer gets more accurate;
save time
and it gets a bit rougher.
Neither side is
simply the right one.
In a hurry, take the fast side;
need precision, the accurate side.
Move the slider
and pick a spot between them.

time spent45%
accuracy89%
A balance of time and accuracy.

More time, more accurate; less time, less accurate. (Where to stop is ours to choose)

This balance
is the heart of all algorithms.
The fast road and the accurate road,
the simple road and the careful road.
Each time, we've been
choosing what to give up
and what to gain.
Knowing a good method
means reading this balance well.

05

The road that brought us here

We've walked a long road.
Starting from solving in order,
lining up, searching,
measuring cost,
splitting, linking, choosing.
We saw that some problems are truly hard,
and that even so,
a good enough answer exists.
Press to look back
over that road at once.

Click what this area gave us, in order, to wrap up

Four things this area gave us. (Good methods, speed, strategy, knowing the limits and trading wisely)

We can't solve
every problem perfectly.
But that doesn't mean
we're powerless.
With fast methods,
with smart strategies,
knowing the limits and trading wisely,
even in front of a hard problem
you can hold
a usable answer in your hand.
That's the power
algorithms give us.

In one lineEven for a hard problem where the perfect answer can't be found fast, a "good enough" one is often quick to find. Some methods go one step further and even guarantee the answer is "within a few percent of the best." It's a trade: give up a little accuracy, gain time. Spend more time and it gets more accurate, less time and less accurate. Where to stop is ours to choose. This is how the whole area closes. We can't solve every problem perfectly, but with fast methods, smart strategies, and knowing the limits, a wise trade puts a usable answer in your hands even in front of a hard problem.
Algorithms
Was this helpful? Support seegongsik