Phase 1 · FoundationsModule 1~30 min read

Introduction to Algorithms

What an algorithm really is, what makes one correct and efficient, and a map of the design paradigms you'll master in this course.

What you'll learn

An algorithm is a precise recipe for turning input into the right output. This course is a tour of the great algorithms and — more importantly — the handful of design paradigms that generate them. Get those paradigms into your bones and you can solve problems you've never seen before.

By the end of this first module you'll be able to:

  • Say precisely what an algorithm is
  • Name the three things that make an algorithm good
  • Recognize the major design paradigms you're about to master
  • Use the two features that make this course different: the language switcher and the animations

What is an algorithm?

An algorithm is a finite sequence of well-defined steps that transforms an input into an output. That's it — a recipe precise enough that a machine (or a careful human) can follow it with no guesswork. Here is a complete algorithm: find the largest number in a list. Read it in Python, Java, C++, or pseudocode — whichever you think in. Your choice sticks for every example in the course.

Language
find_max.py
def find_max(nums):
    best = nums[0]            # assume the first is largest
    for n in nums:
        if n > best:
            best = n          # found a bigger one
    return best

print(find_max([4, 8, 15, 16, 23, 42]))

Notice what makes it an algorithm: every step is unambiguous, it works for any list, and it always stops. Those aren't accidents — they're exactly the properties we demand.

What makes an algorithm good?

Many algorithms solve the same problem, so we need standards. A good algorithm is correct, efficient, and guaranteed to finish:

Three demands on every algorithm

Correct

Gives the right answer on every valid input — provably.

Efficient

Uses as little time and memory as the problem allows.

Terminating

Always finishes — it never loops forever.

Correctness we'll prove with loop invariants and induction (Module 4). Efficiency we'll measure with Big-O (Module 2), so we can compare algorithms without a stopwatch or a particular computer. Most of the course is a hunt for algorithms that stay correct while getting dramatically more efficient.

Key idea

The same problem can have an O(n²) solution and an O(n log n) one — or an exponential brute force and a polynomial dynamic program. Learning which technique unlocks which speedup is the real skill this course builds.

The design paradigms

Almost every algorithm you'll meet is an instance of a few reusable strategies. This whole course is organized around them — here is the map:

The strategies you'll master

Brute force

Try every possibility.

Divide & conquer

Split, solve the pieces, combine.

Greedy

Take the best choice available now.

Dynamic programming

Solve each subproblem once, reuse it.

Backtracking & search

Build, test, and undo dead ends.

Graph algorithms

Model the problem as nodes and edges.

Each phase of the course develops one of these into real, animated algorithms.

We build them roughly from simplest to most powerful: first the tools to analyze algorithms, then searching and sorting, then divide & conquer, greedy, and the crown jewel — dynamic programming — before backtracking, the great graph algorithms, and a final tour of strings, math, and the limits of what computers can do quickly.

How to read this course

Two features make this different from a textbook:

  • Four languages, one click. Every code block has Python, Java, C++, and pseudocode tabs. Pick your language once and the whole course follows.
  • Play the animations. Every algorithm has an interactive player — press Play, or step through one operation at a time with the arrows. Each step has a caption, so you never have to guess what just happened.

Tip

Don't just watch the animations — predict the next step before you press it. Actively guessing is how these techniques become second nature.

Recap & quick check

Key takeaways

  • An algorithm is a finite, precise sequence of steps mapping input to output.
  • A good algorithm is correct, efficient, and guaranteed to terminate.
  • We prove correctness (invariants/induction) and measure efficiency (Big-O).
  • Most algorithms are instances of a few design paradigms — the course is built around them.
  • You can switch code language anytime and play/step through every animation.

Quick check

1. Which best defines an algorithm?

2. Which is NOT one of the three demands on a good algorithm?

3. Why do we measure efficiency with Big-O instead of seconds?

4. What is a 'design paradigm' in this course?

Now let's build the tool that lets us compare any two algorithms fairly. Next up: Module 2 — Algorithm Analysis & Big-O.