Introduction To Algorithm
Introduction To Algorithm
Algorithm
• What is Algorithm
• Algorithm vs Program
• Notation of Algorithm
What is Algorithm?
• a procedure that uses some values or set of values as
input to produce an output
• a list of computational steps that transform the input
into the output.
Simple example of an algorithm based on
children weekday morning routine :
Source code
Translation
Algorithm
• Two kinds of programs process high-level languages into
low-level languages: interpreters and compilers.
Source code
output
Interpreter
output
Executor
Object code
Compiler
Source code
Notation of Algorithm
Human Language
• The most simple ways
• Descriptive and usually use the verbs
Flowchart
• Using symbols.
• Visually describing the flow of program instructions
Pseudocode
• Similar to code
• Doesn’t have any standard pseudo
Flowchart
(watch the video “what is flowchart”)
Example
v1 v2 v3 v4 v5
Human Language
Declaration:
value1, value2, value3, value4, value5, average : real numbers
Algorithm:
1. Enter value1, value2, value3, value4 and value5
2. Calculate the average equal to sum of value1 to value5 then divide
by five
3. Show average calculation results
Pseudocode
Math average Program
{Find the average of the Math values by plugging in Math values of five
students}
Declaration:
value1, value2, value3, value4, value5, average : real
Algorithm:
Input (value1)
input (value2)
input (value3)
input (value4)
Input (value5)
average = (value1 + value2 + value3 + value4 + value5) / 5
Output (average)
What about flowchart?
Individual Task