Upload
taufikhidayat
View
218
Download
3
Tags:
Embed Size (px)
Citation preview
Introduction to Algorithm
Lecture ClassSession 01
T1446 - Algorithm and Programming
Bina Nusantara University
3
Learning Outcome
After taking this course, students should be expected to explain and construct kind of the algorithms in problem solving and explain the
usefulness of java syntax
Introduction to Algorithm
Lecture Outline: • Definition of Algorithm• Programming Language• Algorithm Expression• Pseudocode• Flowchart• NS Diagram
Bina Nusantara University 4
Algorithm Definition
What is an algorithm?– A set of detailed, unambiguous and ordered
instructions developed to describe the progress necessary to produce the desired output from a given input
Bina Nusantara University 5
Example
• Sorting. This algorithm is used to arrange of items or number according of its size.
– Input : a set of positive numbers (a1, a2, a3, …, an)
e.g. 5, 3, 4, 2, 1
– Output: a set of arranged numbers (a’1, a’2, a’3, …, a’n)
e.g. 1, 2, 3, 4, 5• Example of problems which solved using an Algorithm.
– Human Genome Project to identify 100.000 of human DNA genes.
– Search Engines (Yahoo, Google, etc)– GPS Tracking System.
Bina Nusantara University 6
Characteristics of Algorithm
• Input• Output• Definitness• Finiteness• Effectiveness
Bina Nusantara University 7
An algorithm should have the following five characteristics :
Programming Language• Creation of program that is executable by a
computer and performs the required tasks• The high-level languages are English-like and
easy to learn and program• The following well-known high-level languages:
– COBOL (Common Business Oriented Language)– FORTRAN (FORmula TRANslation)– Pascal– C– C++ (an object-oriented language, based on C)– Java This is what we learn in this subject
Bina Nusantara University 8
Expressing an Algorithm
Expressing an Algorithm can be expressed using a method below :
• Pseudocode• Flowchart• NS Diagram
Bina Nusantara University 9
Psedocode
Pseudocode (pronounced SOO-doh-kohd) is a detailed yet readable description of what a computer program or algorithm must do, expressed in a formally-styled natural language rather than in a programming language.—WhatIs.com
Bina Nusantara University 10
Bina Nusantara University 11
Sample of a Pseudocode• Example of phone calls using pseudocode.
BEGINHold up the phoneWHILE not dial
Press dial buttonWHILE not connected
Waiting dialIF connected THEN
WHILE not finish Talking
Hold down the phoneEND
Flowchart
• Schematic representation of process or algorithm.
• Schematic is a illustration of system in simplified or symbolic form.
Bina Nusantara University 12
Flowchart Symbols• The common symbols used to create a
flowchart:
Bina Nusantara University 13
Sample of a Flowchart• Example of Phone Calling Flowchart
Bina Nusantara University 14
Hold up the phone
Press dial button
Waiting
Start
Dialing
No
Yes
Connected
No
Yes
Talking
Finish
No
Yes
Hold down the phone
END
Bina Nusantara
NS Diagram
• NS Diagram is a graphical illustration of structured progamming design.
• Its method is by drawing a table for illustrating an algorithm.
• Founded in 1972 by Isaac Nassi & Ben Shneiderman.
• Known as structograms.
Bina Nusantara
NS Diagram
• Process notation :
• Selection notation:
• Loop notation :– WHILE
– DO-WHILE
Process
Condition
True False
Unfulfilled condition
Proses
Unfulfilled condition
Proses
Sample of NS Diagram• Example of Phone Calling process using NS
Diagram
Bina Nusantara University 17
Hold up the phone
Dialing?
Press dialbutton
Finish?
Talking
Hold down the phone
References• Lesley Anne Robertson, 2006, Simple program
design : a step by step approach, Vol.05, Course Technology. Chapter 1 and 2.
Bina Nusantara University 18