1 | Page
INFORMATICS OLYMPIAD TRAINING
TOPIC: ALGORITHM 1
Contents:
● Meaning of algorithm
● Examples of an algorithm
● Properties of an algorithm
● Expressing an algorithm
o Pseudo codes
o Flowcharting
● Types of algorithm
Meaning of algorithm
An algorithm is a step-by-step procedure to solve a problem. It is a finite number of
steps which if followed will enable a particular task to be accomplished.
Examples of an algorithm
● An algorithm that adds two numbers
● An algorithm that searches for a specific key in a sorted or unsorted data/ list.
CLASS ACTIVITY:
Write an algorithm that calculates the sum of two numbers, a and b
Properties of an algorithm
The Properties of Algorithms
● Input specified
● Output specified
● Definiteness
● Effectiveness
● Finiteness
Expressing an algorithm
An algorithm is expressed using
o Pseudo codes
2 | Page
o Flowcharting
Pseudo codes: It is a description of the steps in an algorithm using a mix of conventions of
programming languages with informal, usually self-explanatory, notation of actions and conditions.
An example is given below:
Step 1 Start
2 Declare the variables, x, y d
3 Enter the values of x and y
3a If x ≥ y then calculate the difference, d = x – y
3b else calculate the difference, d = y - x
4 Print the positive difference, d
5 End
The algorithm above calculates and prints the positive difference between two numbers
Flowcharting: A flowchart is a diagram that depicts a process, system or computer algorithm. It
is a pictorial representation of an algorithm.
CLASS ACTIVITY:
Draw a flowchart to implement the algorithm above (an algorithm that calculates the positive
difference between two numbers, x and y)
Flowchart symbols
Symbol Use/function
Start/Stop
Input/ Output
Process e.g. calculate
Connector or link
Decision e.g. Yes/No
3 | Page
Connector or Link
Storage
A flowchart that calculates and prints the positive difference between two numbers, x and y)
Start
Enter the numbers x, y
Is Yes
X y?
No
Calculate d = x - y
Calculate d = y - x
Print the difference, d
Stop
4 | Page
Types of algorithm
1. Brute Force Algorithm
2. Searching algorithm
3. Sorting Algorithm
4. Recursive Algorithm
5. Randomized Algorithm
6. Pram Algorithm.
ASSIGNMENT:
1. Write an algorithm that calculates the mean of two numbers
2. Draw a flowchart for the task in question 1.
3. Write an algorithm that calculates the value of y for
4. Draw a flowchart to solve the above task in question 3.