TheNightCoder's Tech Diaries

Stop Overthinking Algorithms: 5 Simple Rules That Actually Work

Stop Overthinking Algorithms: 5 Simple Rules That Actually Work

4d42d937c4ae9fef75f77db665ed48b3864fde23f2149c9329833db1d153c5e6.jpg

"What is an algorithm — in plain English?

It's a sequence of actions that leads to a result. But not every sequence qualifies as an algorithm. An algorithm has 5 strict properties.

Today, I'm explaining them with real-life examples — no boring definitions, no math jargon.

P.S. I asked 100 students this question. Only 10 gave a correct answer. Let's fix that."

 

So, What Is an Algorithm?

An algorithm is a clear and precise sequence of actions that takes you from input to output.

In simple words: it's a step-by-step instruction for how to do something.

Examples:

  • A pancake recipe — you follow steps to get pancakes.
  • Packing a backpack for a hike — you put things in a specific order.
  • Making tea — boil water, pour it, wait, drink.

See? You already know algorithms. You just didn't call them that.

5 Properties of Any Real Algorithm

1. Discreteness (Step-by-Step)

An algorithm is split into separate steps. You can't skip a step or do two steps at once.

Example: A recipe says: crack the eggs, then add flour, then mix. You can't mix before cracking the eggs. That's obvious in cooking — but in coding, beginners make this mistake all the time.

dd47b5c3da668227bbc721af238a078ecae104f52d81aa34be141ff2a99d6551.jpg

2. Finiteness (It Must End)

An algorithm must stop after a finite number of steps. No infinite loops allowed.

Example:

❌ "Walk forward until you get bored." — This is NOT an algorithm.

✅ "Walk 500 meters and stop." — This IS an algorithm.

If your program runs forever, it's a bug, not an algorithm.

 

3. Clarity (Understandable)

Every step must be clear to the executor (a computer or a human). No guessing allowed.

Example:

❌ "Add salt to taste." — Ambiguous. What does "to taste" mean?

✅ "Add half a teaspoon of salt." — Clear. No questions.

In programming, ambiguity leads to bugs. Be specific.

 

4. Effectiveness (It Produces a Result)

After executing the algorithm, you must get a result. Not an error, not an infinite loading screen.

Example:

❌Algorithm "Cook pasta" → Ends with a burnt pot? That's not effective.

✅ Algorithm "Cook pasta" → Ends with perfectly cooked pasta.

If there's no result, it's not an algorithm.

 

5. Generality (Mass Applicability)

An algorithm should work for all valid inputs, not just one specific case.

Example:

  • The addition algorithm works for 2+2, 100+500, AND 0+0. It doesn't break.

If your algorithm only works for "2+2" and fails for "100+500", it's not a real algorithm.

 

Types of Algorithmic Processes (Cheat Sheet)

There are 3 types of processes in algorithms. Here's how to remember them:

de47b587ff1464691a6eaea716d993ad750d8f0b46a37342a07cd3b2e329b0e1.png

d3eb4d256eaddb48c049a95d39c40eb13475afdc2b1ec627317862a52d14e981.jpg

Bonus: How to Evaluate a Good Program

Algorithms turn into programs. And programs are judged by these 4 criteria:

  • Reliability — Doesn't crash or produce errors on any data.
  • Efficiency — Runs fast and doesn't eat all your memory.
  • Maintainability — The code is easy to read and fix.
  • Portability — It runs on different computers and operating systems.

 

Final Thoughts (And a Challenge)

"Algorithms aren't scary. They're just step-by-step instructions. You've been using them all your life — from making tea to packing a backpack."

Now, here's my challenge to you:

💡 Think of ONE daily routine (e.g., making coffee or checking your phone). Try to break it down into steps like an algorithm.

 

#algorithm, #programmingbasics, #codingforbeginners, #softwareengineering, #studytips, #tech, #programmingprinciples

How do you rate this article?

2



TheNightCoder's Tech Diaries
TheNightCoder's Tech Diaries

Practical guides on web development and life hacks for IT enthusiasts.

Publish0x

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.

Page not displaying correctly?