Skip to content
AgileLogics
Beginner 4 min read

What Is an Algorithm?

An algorithm is a step-by-step method for solving a specific problem — independent of any particular programming language.

Real-world analogy: directions from your house to the airport are an algorithm. The steps ("turn left, drive 2 miles, take the highway exit") solve the problem ("get to the airport") regardless of what car you're driving. The car is like the programming language — different cars (languages) can follow the same directions (algorithm).

A simple algorithm, written in plain English, for finding the largest number in a list:

1. Assume the first number is the largest so far.
2. Look at each remaining number in the list.
3. If a number is bigger than the largest so far, replace it.
4. After checking every number, the largest so far is the answer.

Every program you write is really an algorithm, translated into a language's specific syntax.

Practice

Write down, in plain English steps (no code), an algorithm for checking whether a word is a palindrome (reads the same forwards and backwards, like "level").

Show solution
1. Remove spaces and make every letter the same case.
2. Reverse the word.
3. Compare the reversed word to the original.
4. If they match, it's a palindrome.