You are on page 1of 17

Introduction to

Algorithm

Mira Chandra Kirana


Polibatam-BioTech
Content

• 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 :

1. Start What about you?


2. Get up I convinced that you
3. Shower are capable to make
your own simple
4. Get dressed algorithm.
5. Eat breakfast Give simple example
of algorithm base on
6. If weather is “sunny”
your daily activity!
7. Walk to the school
8. else
9. Go to the school with parents
10. Stop
Algorithm vs program

• The algorithm  process and the programming 


implementation  specific to coding language,
environment, and how the rest of the app works.
• Programming  taking an algorithm and encoding it into
 a programming language  in order to be executed by
a computer
• Algorithm will be translated to be source code.
• Source code  programming language  commonly in High
level Programming, such C/C++, Java, etc

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

How to count the average of five students Math


values?

v1 v2 v3 v4 v5
Human Language

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 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

• Create an algorithm for calculating the area and


circumference of the rectangle. Create 3 types of algorithm
notation.

Write your task in word named T1_NIM, upload in learning


before 28 August 2021 at 23.59 WIB

You might also like