Sitemap
Kandeeparaja Vithooran

Kandeeparaja Vithooran

Problem Solving using Algorithms

2 min readAug 18, 2023

An algorithm is a method to show the steps in solving a problem. An algorithm is a step-by-step procedure for solving a problem. The need for this is to present a way to solve the problem with a plan.

Control Structures

Three types of control structures are used in an algorithm.

i. Sequence

ii. Selection

iii. Repetition

  1. Sequence

If the steps from the beginning to the end of an algorithm are carried out in a strict order, it is called a sequence.

2. Selection

Selection is a situation where steps are executed depending on whether a condition of an algorithm is satisfied or not. There are two choices; if the condition is satisfied, one is selected, and if it is not satisfied, the other is selected.

Examples of selection

1. Admitting a child to Grade 1:

If a child is below 5 years old as of the 31st of January, that year

The child cannot be admitted to school If not

The child can be admitted to school

2. Passing a subject:

If the mark is 35 or more, It is a Pass

Get Kandeeparaja Vithooran’s stories in your inbox

Join Medium for free to get updates from this writer.

If not, It is a Fail

3. Repetition

If one or several steps of an algorithm are repeated until a condition is satisfied, it is called repetition.

Examples

1. Let us consider the process of a class teacher marking the attendance register.

(1) Call the first name on the register

(2) Mark 1 if the student is present

(3) Mark 0 if the student is absent

(4) Call the name of the next student

(5) Repeat steps (2), (3) and (4) till the

last name of the register is called

2. Let us consider the process of reading a paragraph and calculating the number of words you read.

(1) Read the first word of the paragraph

(2) Number of words: 1

(3) Read the next word

(4) Add 1 to the number of words

(5) Repeat steps (3) and (4) till the end of the paragraph

(6) After reading the paragraph, indicate the number of words

--

--