18

Pert01_Introduction to Algorithm (L)_T1446.ppt

Embed Size (px)

Citation preview

Page 1: Pert01_Introduction to Algorithm (L)_T1446.ppt
Page 2: Pert01_Introduction to Algorithm (L)_T1446.ppt

Introduction to Algorithm

Lecture ClassSession 01

T1446 - Algorithm and Programming

Page 3: Pert01_Introduction to Algorithm (L)_T1446.ppt

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

Page 4: Pert01_Introduction to Algorithm (L)_T1446.ppt

Introduction to Algorithm

Lecture Outline: • Definition of Algorithm• Programming Language• Algorithm Expression• Pseudocode• Flowchart• NS Diagram

Bina Nusantara University 4

Page 5: Pert01_Introduction to Algorithm (L)_T1446.ppt

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

Page 6: Pert01_Introduction to Algorithm (L)_T1446.ppt

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

Page 7: Pert01_Introduction to Algorithm (L)_T1446.ppt

Characteristics of Algorithm

• Input• Output• Definitness• Finiteness• Effectiveness

Bina Nusantara University 7

An algorithm should have the following five characteristics :

Page 8: Pert01_Introduction to Algorithm (L)_T1446.ppt

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

Page 9: Pert01_Introduction to Algorithm (L)_T1446.ppt

Expressing an Algorithm

Expressing an Algorithm can be expressed using a method below :

• Pseudocode• Flowchart• NS Diagram

Bina Nusantara University 9

Page 10: Pert01_Introduction to Algorithm (L)_T1446.ppt

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

Page 11: Pert01_Introduction to Algorithm (L)_T1446.ppt

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

Page 12: Pert01_Introduction to Algorithm (L)_T1446.ppt

Flowchart

• Schematic representation of process or algorithm.

• Schematic is a illustration of system in simplified or symbolic form.

Bina Nusantara University 12

Page 13: Pert01_Introduction to Algorithm (L)_T1446.ppt

Flowchart Symbols• The common symbols used to create a

flowchart:

Bina Nusantara University 13

Page 14: Pert01_Introduction to Algorithm (L)_T1446.ppt

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

Page 15: Pert01_Introduction to Algorithm (L)_T1446.ppt

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.

Page 16: Pert01_Introduction to Algorithm (L)_T1446.ppt

Bina Nusantara

NS Diagram

• Process notation :

• Selection notation:

• Loop notation :– WHILE

– DO-WHILE

Process

Condition

True False

Unfulfilled condition

Proses

Unfulfilled condition

Proses

Page 17: Pert01_Introduction to Algorithm (L)_T1446.ppt

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

Page 18: Pert01_Introduction to Algorithm (L)_T1446.ppt

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