Last updated on October 8th, 2023 at 02:50 pm

In this article, we will explore what an algorithm is. However, before exploring algorithms in information technology, we also need to look at the problem defining diagram.

The IPO or problem defining diagram is a tool the Caribbean Examination Council uses in problem definition stage of the problem solving process. It is a simple table that contains the input, process, and output of the problem being solved. Once you have created your problem defining diagram, it is time to develop the algorithm, which is the blueprint of the final program to be written.

In this series of lessons, we will look at many Problem defining diagrams and algorithms, but in this lesson, we will look at:

- What exactly an algorithm is;
- Characteristics of an algorithm;
- Two types of algorithms; and
- How to prepare a pseudocode algorithm;

## What is an algorithm?

An algorithm is the actual set of instructions that lists the step-by-step solution to a problem.

Algorithms are used in information technology, computer science, and mathematics as part of their problem solving process. An algorithm is to a computer program what a blueprint is to a building.

## Characteristics of an algorithm

The following items are the characteristics of an algorithm:

- A finite number of steps – it always has a beginning and an end;
- You should write the instructions in a clear manner that does not lend itself to misinterpretation;
- An algorithm is language-independent;
- While an algorithm may have no inputs, it must have at least one output; and
- Algorithms shouldn’t have redundancies.

## Two types of algorithms

While there are several types of algorithms in we will only look at two:

- Pseudocode and
- Flow chart.

## How to prepare a pseudocode algorithm

To prepare an algorithm, we always begin by naming it. To name our algorithm, we always give it a name that has meaning. That is, the name of the algorithm should reflect what it does. For instance, if an algorithm finds the total of several numbers, we may name it **total** or **addition**. So we write **Algorithm total; **or **Algorithm addition;**

Next, we declare and initialize the variables. To learn more about types of variables and data types in general, visit our article on variables vs. consonants.

**Integer age1 = 14;**

The word **integer** indicates the **type of variable**, and the word **age** is the name of the variable. As with the name of the program, the variable name must indicate the type of information being stored in it. Using the word **age1** as the variable name indicates that the information being stored in this variable is an age.

The next thing to do is a breakdown of the process to solve the problem.

Finally, we need to display the output.

## Example of a simple problem defining diagram and pseudocode

Imagine you were asked to prepare a program that would take in the names and grades of three students and find and print the highest and average grades.

## Problem defining diagram

Input | Process | Output |
---|---|---|

grade1 | 1. Read grade1, grade2, grade3. | highestGrade |

grade2 | 2. Find the highestGrade. | averageGrade |

grade3 | 3. Find the averageGrade. | |

4. Print the highestGrade. | ||

5. Print the averageGrade. |

## Pseudocode example

**Algorithm averageGrade**;

**start**

- real grade1 = 0
- real grade2 = 0
- real grade3 = 0
- Print: Please enter the first grade;
- read: grade1;
- Print: Please enter the second grade;
- read: grade2;
- Print: Please enter the third grade;
- read: grade3;
- averageGrade = (grade1 + grade2 + grade3)/3;
- If(grade1>grade2)
- a. highestGrade = grade1;

- else
- a. HighestGrade = grade2

- if(highestGrade < grade3)
- a. highestGrade = grade3

- Print: highestGrade;
- Print: averageGrade;

**stop.**

Are you interested in learning to prepare a flowchart algorithm? We have you covered with this article on the flowchart algorithm and how to prepare one.

Once we have prepared our algorithm, we need to use a trace table for accuracy. After all, you would not build the house without first ensuring the blueprint is error-free, would you? Visit our article entitled an introduction to trace tables to learn more.

To learn how to problem solve using the problem-defining diagram, algorithm, trace table, and program, we have a series of lessons for you. If you believe you are ready, you may proceed to lesson 1 – what is Pascal?

## Before you go

We try our best to ensure that the information we provide is clear, adequate, and error-free. However, if you have questions or comments, be sure to leave them in the section provided below, and we will be sure to get back to you in a timely manner.