← Back to Roadmap

Algorithms & Logic

Easy

In plain terms

An algorithm is a finite set of steps that, when followed, solve a specific problem. It has a clear start and end, and each step is unambiguous. For example, "find the largest number in a list" can be solved by an algorithm: start with the first number as max, then compare each next number and update max if larger.

Logic in programming means making decisions (if/else) and repeating actions (loops) based on conditions. Boolean logic (true/false, AND, OR, NOT) helps you express those conditions. Strong algorithmic thinking makes you a better programmer in any language.

What you need to know

  • Algorithm: clear steps to solve a problem
  • Logic: conditions and control flow
  • Same algorithm can be written in any language

Example

Code is language-agnostic in spirit; adapt the idea to your language:

// Algorithm: find max in array
function findMax(arr) {
  let max = arr[0];
  for (let i = 1; i < arr.length; i++) {
    if (arr[i] > max) max = arr[i];
  }
  return max;
}
findMax([3, 1, 4, 1, 5]);  // 5

Why this matters

Algorithmic thinking is tested in almost every technical interview (coding rounds, system design). Showing you can turn a problem into clear steps and handle edge cases sets you apart.

How it connects

Algorithms use variables to hold state, conditionals for decisions, and loops for repetition—directly tying to the previous topic. Later, OOP and design patterns help you express and organize algorithms in large codebases.

Interview focus

Be ready to explain these; they come up often.

  • Define an algorithm: finite, unambiguous steps with a clear goal.
  • Explain time/space complexity in simple terms (e.g. "one loop over the list = O(n)").
  • Give an example: e.g. finding max in array, and mention edge cases (empty array, one element).

Learn more

Dive deeper with these resources: