An algorithm is a sequence of instructions/actions to solve some problem. The instructions/actions are short and precise, and there is a small, fixed set of possible instructions/actions. Here is an example algorithm for the problem “How do I get to the bathroom?”
Algorithm for the Bathroom Problem:
- Face south
- Walk 12 feet
- Turn west
- Walk 15 feet
- Turn south
- Walk 21 feet
- Turn east
- Walk 3 feet
In the above algorithm, the allowable instructions/actions are “Face [[direction]]” and “Walk [[X feet]],” where [[direction]] is one of four possible directions of the compass and [[X feet]] is a number.
The allowable set of instructions/actions is what constitutes a programming language. A real programming language, such as JAVA or Python, has instructions/actions for reading, writing, and manipulating numbers and letters.