The words you are searching are inside this book. To get more targeted content, please make full-text search by clicking here.
Discover the best professional documents and content resources in AnyFlip Document Base.
Search
Published by inaazlin, 2018-12-12 21:07:38

2.1(a,b) Introduction to Design a Solution

Introduction to Design a Solution

Keywords: Design a Solution

2.1 Design a Solution

a) Describe algorithm (Pseudocode &
Flowchart) .
b) Solve a given problem using algorithm.

Edited by: azlina mohamad | computer science
unit



What is algorithm?

Definition:

• A number of steps arranged in order to solve a problem.
• A step-by-step instructions that will transform the input into

the output.
Can be represented by using

i. pseudocode
ii. flowchart.

Tools to develop algorithm:

1. Pseudo code 2. Flowchart
• Informal language used • Graphical representation
to develop algorithms.
of an algorithm.

• Similar to everyday • Special-purpose symbols
English. connected by arrows
(flow lines).

Tools to develop algorithm:

11.. Pseudo ccooddee 22.. FFlloowwcchhaarrtt

START

1 start 2 Statement 1
statement 1 Statement 2
statement 2

3 stop

STOP

Format to represent an algorithm in
flowchart

The statement START
refers to any input,
output & process Statement 1
involved Statement 2

STOP

Symbols used in flowchart:

Graphic Name Meaning
Symbol

Terminator indicates the beginning and end
Symbol points of an algorithm

(terminator)

Process Symbol shows a process/an operation other
(rectangle) than input, output or selection

Input-Output
Symbol shows an input or output operation

(parallelogram)

Symbols used in flowchart:

Graphic Name Meaning
Symbol

Disk Storage Input- indicates input from or output
Output Symbol to disk storage
(cylinder)

Printer Output shows hardcopy printer output
Symbol

Selection Symbol shows a selection process for
(diamond) two-way selection

Symbols used in flowchart:

Graphic Name Meaning
Symbol

Flow Lines (arrow) indicates the logical sequence of
execution steps in the algorithm

Off-Page provides continuation of a
Connector logical path on another page

On-Page provides continuation of a

Connector (circle) logical path at another point in

the same page

Symbols used in flowchart:

Connector used in flowchart: On-page connector

START

INPUT x sum = x + y + z
INPUT y PRINT sum
INPUT z STOP

Symbols used in flowchart:

Connector used in flowchart: Off-page connector

START
INPUT x
INPUT y
INPUT z

Symbols used in flowchart:

Continuation from
previous page

sum = x + y + z

PRINT sum

STOP

Solve all the problems by
using pseudocode and

flowchart.

Example Problem 1

Step 1 : Identify IPO

Calculate and display the perimeter of a square.

Input side
Process
Output Calculate the perimeter of a
square

perimeter

Step to solve the
problems by using

pseudocode.

Example Problem 1

Step 2 : Transfer IPO to Pseudocode

IPO Analysis Pseudocode

START

Start and stop the procedure

STOP

Example Problem 1

Step 2 : Transfer IPO to Pseudocode

IPO Analysis Pseudocode
Input: side START

READ side

STOP

Example Problem 1

Step 2 : Transfer IPO to Pseudocode

IPO Analysis Pseudocode

Input: side START
Process: Calculate perimeter of READ side
square
perimeter = 4 x side

STOP Write process an
equation involved

Example Problem 1

Step 2 : Transfer IPO to Pseudocode

IPO Analysis Pseudocode
START

Input: side READ side

Process: Calculate perimeter of square perimeter = 4 x side

Output: perimeter PRINT perimeter

STOP

Step to solve the
problems by using

flowchart.

Example Problem 1

Step 2 : Transfer IPO to Flowchart

IPO Analysis Flowchart

START

STOP

Example Problem 1

Step 2 : Transfer IPO to Flowchart

IPO Analysis Flowchart
Input: side
START

READ side

STOP

Example Problem 1

Step 2 : Transfer IPO to Flowchart

IPO Analysis Flowchart

Input: side START
Process: Calculate perimeter of square
READ side

perimeter = 4 x side

STOP

Example Problem 1

Step 2 : Transfer IPO to Flowchart

IPO Analysis Flowchart

Input: side START
Process: Calculate perimeter of square
Output: perimeter READ side

perimeter = 4 x side

PRINT perimeter

STOP

Example Problem 2

Step 1 : Identify IPO

Converts length in meter to centimeter and kilometer.

Input meter
Process
Output Converts meter to centimeter
and kilometer

centimeter, kilometer

Example Problem 2

Step 2 : Transfer IPO to Pseudocode

IPO Analysis Pseudocode

START

STOP

Example Problem 2

Step 2 : Transfer IPO to Pseudocode

IPO Analysis Pseudocode
Input: meter START

READ meter

STOP

Example Problem 2

Step 2 : Transfer IPO to Pseudocode

IPO Analysis Pseudocode

START

Input: meter READ meter

Process: Convert meter to centimeter = meter x 100
centimeter and kilometer kilometer = meter / 1000

STOP

Example Problem 2

Step 2 : Transfer IPO to Pseudocode

IPO Analysis Pseudocode

START

Input: meter READ meter

Process: Convert meter to centimeter = meter x 100
centimeter and kilometer kilometer = meter / 1000

Output: centimeter, kilometer print centimeter, kilometer

STOP

Example Problem 2

Step 2 : Transfer IPO to Flowchart

IPO Analysis Flowchart

START

STOP

Example Problem 2

Step 2 : Transfer IPO to Flowchart

IPO Analysis Flowchart
Input: meter
START

READ meter

STOP

Example Problem 2

Step 2 : Transfer IPO to Flowchart

IPO Analysis Flowchart

Input: meter START
Process: Convert meter to
centimeter and kilometer READ meter
centimeter = meter x 100

kilometer = meter / 1000

STOP

Example Problem 2

Step 2 : Transfer IPO to Flowchart

IPO Analysis Flowchart

Input: meter START
Process: Convert meter to
centimeter and kilometer READ meter
Output: centimeter, kilometer
centimeter = meter x 100
kilometer = meter / 1000

PRINT centimeter,
kilometer

STOP

Example Problem 3

• Write an IPO analysis for a program that
calculate and display the addition,
subtraction, multiplication and division of two
numbers.

Input number 1, number 2
Process
Output Calculate the addition, subtraction,
multiplication and division of two
numbers.

addition, subtraction, multiplication
and division


Click to View FlipBook Version