What an algorithm really is
An algorithm is a set of steps written in order to solve a problem. The steps must be clear enough that two people reading them follow the same action, and short enough to finish. This definition is useful because it gives you a test you can apply to your own notes: if a step could be read in two ways, the algorithm is not ready yet. A recipe, a route to school and a method for finding the greatest common divisor are all algorithms; the level of detail changes, but the requirement of clear, ordered steps does not.
Five properties to check
A good algorithm has five properties. Determinism means each step has one meaning. Ordering means the steps follow a definite sequence. Finiteness means the process ends after a limited number of steps. Input and output mean it receives data and produces a result. Effectiveness means every step can actually be carried out. When one of these is missing, the algorithm fails in a specific way: an ambiguous step confuses the reader, an endless loop never returns, and a step that cannot be performed stops the whole plan.
Writing steps as pseudocode
Pseudocode is a way of writing an algorithm in ordinary language with a little structure. You number the steps, use short commands such as read, compare and print, and keep the wording close to natural speech. Because no programming language rules apply, you can focus on whether the logic is right. A useful exercise is to write the solution for a simple task, such as finding the largest of three numbers, then read it aloud and act it out with sample values. If you get stuck following your own instructions, the algorithm needs another pass.
Seeing the branches in a flowchart
A flowchart draws the same steps with symbols. A process box shows an action, an input-output box shows data entering or leaving, and a decision box asks a yes-or-no question. The decision box has exactly two outgoing arrows, one for each answer, and that is what makes conditional behaviour visible. Following the arrows with a finger on a simple example reveals paths you may not have considered, such as what happens when two numbers are equal. Diagrams and pseudocode describe the same algorithm, so they should always agree.
Syntax errors and logic errors
A syntax error breaks the rules of the programming language, so the program stops before it starts. A logic error is different: the program runs to the end but produces the wrong answer because a step was written in the wrong order or a condition points the wrong way. The first kind is usually reported with a line number, while the second is found by testing with values whose answer you already know. Debugging means choosing the right method for the right kind of error; rereading the code helps with neither if you do not know which kind you have.
The working order and a short routine
Problem solving follows a loop: understand the question, plan the steps, write them, test them, and improve what failed. Keep the problem definition in one sentence before you plan, because a vague goal produces a vague algorithm. For practice, take one small task and write it three ways: a sentence, pseudocode and a flowchart. Then test it with two ordinary inputs and one unusual one. The comparison between the three versions is where most learning happens, since each format exposes a different kind of mistake.
Frequently asked questions
Which of these is a property of an algorithm?
Effectiveness is one of the five properties: every step must be applicable in practice. The others are determinism, ordering, finiteness, and having input and output.
How many exits does a decision box have in a flowchart?
It has two exits, one for yes and one for no. These two branches are what allow a program to choose between different paths depending on a condition.
What is the difference between a syntax error and a logic error?
A syntax error stops the program before it runs because a language rule is broken. A logic error lets the program run but gives the wrong result, so it is found by testing with known values.
Create a free account — save your progress
Save your notes