Sign in

Algorithms

Introduction to algorithms, characteristics, and practical design

Understand the precise definition of an algorithm, identify its fundamental characteristics, and analyze time and space complexity with concrete Python implementations.

Plain words. One step at a time. Nothing here assumes you already know the idea.

The idea

An algorithm is a finite, well-defined sequence of unambiguous instructions designed to solve a specific computational problem or accomplish a specific task. It accepts zero or more valid inputs, performs a deterministic series of operations, and produces an output within a bounded amount of time.

See it

Consider a standard kitchen recipe for baking bread.

1 of 4

You will need. Basic familiarity with reading simple Python syntax · Understanding of basic mathematical operations like addition and division

One pass

Step 1 of 3

At its simplest, an algorithm is a clear procedure for solving a recurring problem. For an algorithm to be computationally useful, it must satisfy five core criteria: finiteness (it must terminate after a finite number of steps), definiteness (every operation must be precisely stated), input (it takes zero or more inputs), output (it produces at least one result), and effectiveness (every step must be feasible to carry out).

Smallest version

A straightforward algorithm to find the maximum integer in a non-empty list

def find_maximum(numbers):
    current_max = numbers[0]
    for value in numbers[1:]:
        if value > current_max:
            current_max = value
    return current_max

sample_data = [4, 9, 2, 7]
print(find_maximum(sample_data))

Keep these

  • An algorithm must always terminate and produce an unambiguous outcome.
  • Every step relies strictly on deterministic conditions and values computed so far.

Try one

Compute the sum of a list

easy

Start the five-step lesson

Also on MonksBit