0% found this document useful (0 votes)
169 views14 pages

MODULE 4 Lesson 1 Algorithm Development

The document discusses algorithms and their properties. It defines an algorithm as a set of step-by-step instructions to perform a task and describes the three main types as sequential, branching, and looping. It provides examples of algorithms to find the area of a circle, calculate the sum of two numbers, and convert between Fahrenheit and Celsius scales. Finally, it outlines five key properties of algorithms including finiteness, definiteness, inputs, outputs, and effectiveness.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
169 views14 pages

MODULE 4 Lesson 1 Algorithm Development

The document discusses algorithms and their properties. It defines an algorithm as a set of step-by-step instructions to perform a task and describes the three main types as sequential, branching, and looping. It provides examples of algorithms to find the area of a circle, calculate the sum of two numbers, and convert between Fahrenheit and Celsius scales. Finally, it outlines five key properties of algorithms including finiteness, definiteness, inputs, outputs, and effectiveness.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

PhilCST

PHILIPPINE COLLEGE OF SCIENCE & TECHNOLOGY


OLD NALSIAN ROAD, BRGY. NALSIAN, CALASIAO, PANGASINAN

Algorithm
Development
PhilCST
PHILIPPINE COLLEGE OF SCIENCE & TECHNOLOGY
OLD NALSIAN ROAD, BRGY. NALSIAN, CALASIAO, PANGASINAN

Algorithm

Algorithm . Set of step-by-step instructions that perform a specific task or


operation. “Natural” language NOT programming language

Pseudocode. Set of instructions that mimic programming language


instructions
PhilCST
PHILIPPINE COLLEGE OF SCIENCE & TECHNOLOGY
OLD NALSIAN ROAD, BRGY. NALSIAN, CALASIAO, PANGASINAN

3 Types of Algorithm

1. Sequence. a sequential algorithm or serial algorithm is


an algorithm that is executed sequentially – once
through, from start to finish, without other processing
executing – as opposed to concurrently or in parallel.
The term is primarily used to contrast with concurrent
algorithm or parallel algorithm; most standard
computer algorithms are sequential algorithms.
Concurrency and parallelism are in general distinct
concepts, but they often overlap – many distributed
algorithm are both concurrent and parallel – and thus
"sequential" is used to contrast with both, without
distinguishing which one. If these need to be
distinguished, the opposing pairs sequential/concurrent
and serial/parallel may be used.
PhilCST
PHILIPPINE COLLEGE OF SCIENCE & TECHNOLOGY
OLD NALSIAN ROAD, BRGY. NALSIAN, CALASIAO, PANGASINAN

2. Branching (Selection). A binary decision


based on some condition. If the condition
is true, one of the two branches is
explored; if the condition is false, the
other alternative is taken. This is usually
represented by the ‘if-then’ construct in
pseudo-codes and programs. In
flowcharts, this is represented by the
diamond-shaped decision box. This
structure is also known as the selection
structure.
PhilCST
PHILIPPINE COLLEGE OF SCIENCE & TECHNOLOGY
OLD NALSIAN ROAD, BRGY. NALSIAN, CALASIAO, PANGASINAN

3. Loop (Repetition). The loop allows a statement or a


sequence of statements to be repeatedly executed based on
some loop condition. It is represented by the ‘while’ and ‘for’
constructs in most programming languages, for unbounded
loops and bounded loops, respectively. (Unbounded loops
refer to those whose number of iterations depends on the
eventuality that the termination condition is satisfied;
bounded loops refer to those whose number of iterations is
known before-hand.) In the flowcharts, a back arrow hints
the presence of a loop. A trip around the loop is known as
iteration. You must ensure that the condition for the
termination of the looping must be satisfied after some
finite number of iterations, otherwise it ends up as an
infinite loop, a common mistake made by inexperienced
programmers. The loop is also known as the repetition
structure.
PhilCST
PHILIPPINE COLLEGE OF SCIENCE & TECHNOLOGY
OLD NALSIAN ROAD, BRGY. NALSIAN, CALASIAO, PANGASINAN

Problem 1: Find the area of a Circle of radius r. Inputs to the


algorithm: Radius r of the Circle. Expected output: Area of
the Circle

Algorithm: Step1: Read\input the Radius r of the Circle Step2:


Area PI*r*r // calculation of area Step3: Print Area

Example of Algorithm
PhilCST
PHILIPPINE COLLEGE OF SCIENCE & TECHNOLOGY
OLD NALSIAN ROAD, BRGY. NALSIAN, CALASIAO, PANGASINAN

Problem2: Write an algorithm to read two numbers and find their sum.
Inputs to the algorithm:
First num1. Second num2.
Expected output:
Sum of the two numbers.

Algorithm:
Step1: Start
Step2: Read\input the first num1.
Step3: Read\input the second num2.
Step4: Sum num1+num2 // calculation of sum
Step5: Print Sum Step6: End
PhilCST
PHILIPPINE COLLEGE OF SCIENCE & TECHNOLOGY
OLD NALSIAN ROAD, BRGY. NALSIAN, CALASIAO, PANGASINAN

Problem 3: Convert temperature Fahrenheit to Celsius Inputs to the


algorithm: Temperature in Fahrenheit Expected output: Temperature in
Celsius
Algorithm:
Step1: Start
Step 2: Read Temperature in Fahrenheit F
Step 3: C 5/9*(F32)
Step 4: Print Temperature in Celsius: C
Step5: End
PhilCST
PHILIPPINE COLLEGE OF SCIENCE & TECHNOLOGY
OLD NALSIAN ROAD, BRGY. NALSIAN, CALASIAO, PANGASINAN

1) Finiteness: An algorithm must always terminate after a


finite number of steps. It means after every step one reach
closer to solution of the problem and after a finite number of
steps algorithm reaches to an end point.

Properties of Algorithm by Donald Ervin


Knuth
PhilCST
PHILIPPINE COLLEGE OF SCIENCE & TECHNOLOGY
OLD NALSIAN ROAD, BRGY. NALSIAN, CALASIAO, PANGASINAN

2) Definiteness: Each step of an algorithm


must be precisely defined. It is done by well
thought actions to be performed at each
step of the algorithm. Also the actions are
defined unambiguously for each activity in
the algorithm.
PhilCST
PHILIPPINE COLLEGE OF SCIENCE & TECHNOLOGY
OLD NALSIAN ROAD, BRGY. NALSIAN, CALASIAO, PANGASINAN

3) Input: Any operation you perform need some beginning


value/quantities associated with different activities in the
operation. So the value/quantities are given to the algorithm
before it begins.
PhilCST
PHILIPPINE COLLEGE OF SCIENCE & TECHNOLOGY
OLD NALSIAN ROAD, BRGY. NALSIAN, CALASIAO, PANGASINAN

4) Output: One always expects output/result (expected


value/quantities) in terms of output from an algorithm. The
result may be obtained at different stages of the algorithm.
If some result is from the intermediate stage of the
operation, then it is known as intermediate result and result
obtained at the end of algorithm is known as end- result. The
output is expected value/quantities always have a specified
relation to the inputs.
PhilCST
PHILIPPINE COLLEGE OF SCIENCE & TECHNOLOGY
OLD NALSIAN ROAD, BRGY. NALSIAN, CALASIAO, PANGASINAN

5) Effectiveness: Algorithms to be
developed/written using basic operations.
Operations should be basic, so that even
they can in principle be done exactly and in
a finite amount of time by a person, by
using paper and pencil only..
PhilCST
PHILIPPINE COLLEGE OF SCIENCE & TECHNOLOGY
OLD NALSIAN ROAD, BRGY. NALSIAN, CALASIAO, PANGASINAN

References:
https://www.examupdates.in
https://en.wikipedia.org/wiki/Sequential_algorithm
Madhi Amir (2013). Algorithm and Flow Chart. https://faradars.org/wp-
content/uploads/2015/07/Algorithm-and-Flow-Chart.pdf

You might also like