0% found this document useful (0 votes)
10 views20 pages

CBCP2101 Topic 2 - Algorithm

This document discusses algorithms and their representations. It begins by defining an algorithm as a step-by-step problem-solving method that must be completed in a limited time. Algorithms can be represented through flowcharts or pseudo code. The document provides examples of each representation and their rules. It explains how to create flowcharts and write pseudo code, including specifying the required symbols, formulas, and data. Key aspects like sequential steps, variables, data types, arithmetic operations, and input/output are highlighted. Overall, the document aims to explain what algorithms are and how they can be visually depicted.

Uploaded by

Abdul Rohim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views20 pages

CBCP2101 Topic 2 - Algorithm

This document discusses algorithms and their representations. It begins by defining an algorithm as a step-by-step problem-solving method that must be completed in a limited time. Algorithms can be represented through flowcharts or pseudo code. The document provides examples of each representation and their rules. It explains how to create flowcharts and write pseudo code, including specifying the required symbols, formulas, and data. Key aspects like sequential steps, variables, data types, arithmetic operations, and input/output are highlighted. Overall, the document aims to explain what algorithms are and how they can be visually depicted.

Uploaded by

Abdul Rohim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Algorithm

TOPIC 2

JASPAL KAUR
FTAS
Learning Outcomes:
By the end of this topic, you should be able to:
1. Solve problems by using two algorithm representative
techniques;
2. Test the algorithm execution process with step-by-step detailing;
and
3. Build an algorithm.

2
What is an algorithm?
Algorithm is a step-by-step problem-solving method in a limited
time.

3
Algorithm Representation
Algorithms can be conceptual or abstract.
Two algorithm representations:
1. Flow chart
2. Pseudo code

4
Flow chart representation

5
Guide on creating flowcharts:
1. Identify the symbol used, according to its function
2. Get the right formula
3. Make sure that the appropriate data is used
4. Test the flowchart by tracing each symbol, comparing it with the
expected output.

6
Example of flowchart:

7
Example of
flowchart:

8
Example of
flowchart:

9
Example of
flowchart:

10
Example of
flowchart:

11
Pseudo-code Representation
Pseudo-code or false codes are instructions that mimic the program
code (actual program instructions).

12
Rules of writing Pseudo-codes
● Every step in an algorithm should not have more than two actions
● Steps in an algorithm are executed in sequence
● The word End or Stop is used to show that the process has ended.
● The action that is allowed includes declaring variable names to identify the set
of variables that have a corresponding data type.
● Types of data might be in the form of integer, real, character or others.
● To give an initial value to a variable (if applicable).
● To use arithmetic symbols to state the addition, subtraction, multiplication and
division operations, as well as brackets to show operation priority.
● A ← B represents assigning the value of variable B to A.

13
Rules of writing Pseudo-codes ...
● The relational operators below are used to state the relationship between two-
values:
○ < less than
○ <= less than or equals to
○ > more than
○ >= more than or equals to
○ != not equal
○ == equal
● The use of sentence is allowed, if it states the meaning accurately.
● Read/Input/Get shows the data given to the algorithm as input.
● Print/Report/Write/Output/Display shows the result obtained by the algorithm.

14
15
Examples of Pseudo-codes
1.0 Start
2.0 Set total to zero
3.0 Set grade counter to one
4.0 While grade counter is less than or equal to ten
4.1 Input the next grade
4.2 Add the grade into the total
5.0 Set the class average to the total divided by ten
6.0 Print the class average.
7.0 End

16
Examples of
Pseudo-codes

17
18
Video

19
End of Topic 2: Algorithm

Thank you!

OUM 20

You might also like