220 likes | 502 Views
Introduction to Algorithm Session 1. Course : T0974-Algorithm & Object-Oriented Programming I Year : 2011. Learning Outcome. After taking this course, students should be expected to explain and discuss their own Algorithms. Lecture Outline. Definition of Algorithm
E N D
Introduction to AlgorithmSession 1 Course : T0974-Algorithm & Object-Oriented Programming I Year : 2011
Learning Outcome After taking this course, students should be expected to explain and discuss their own Algorithms.
Lecture Outline • Definition of Algorithm • Characteristics of Algorithm • Programming Language • Algorithm Expression • Pseudocode • Flowchart • NS Diagram
AlgorithmDefinition • A precise rule (or set of rules) specifying how to solve some problemwordnetweb.princeton.edu/perl/webwn • A procedure used to solve a mathematical or computational problem or to address a data processing issue. In the latter sense, an algorithm is a set of step-by-step commands or instructions designed to reach a particular goal. www.colorado.edu/geography/gcraft/gloss/glossary.html
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.
Characteristics of Algorithm • Input • Output • Definitness • Finiteness • Effectiveness An algorithm should have the following five characteristics :
Programming Language • A sequence of instructions that a computer can interpret and execute) "the program required several hundred lines of code” --wordnetweb.princeton.edu • Instruction is a line of code written as part of a computer program –wordnetweb.princeton.edu • Example : • COBOL (Common Business Oriented Language) • FORTRAN (FORmula TRANslation) • Ada (Ada Lovelace) • C • C++ (C Based Object-Oriented Programming Languange) • Java
Expressing an Algorithm Expressing an Algorithm can be expressed using a method below : • Pseudocode • Flowchart • NS Diagram
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
Pseudocode BEGIN Hold up the phone WHILE not dial Press dial button WHILE not connected Waiting dial IF connected THEN WHILE not finish Talking Hold down the phone END Example of phone calls using pseudocode.
Pseudocode BEGIN Number = Input Number Result = Number % 2 IF Result = 0 THEN Print “The number is even number” ELSE THEN Print “The number is odd number” END Example of Pseudocode to determine odd-even number
Flowchart • Schematic representation of process or algorithm. • Schematic is a illustration of system in simplified or symbolic form.
Flowchart • Notasi Proses, Data Entry • Selection : • Flow Lines : • Input/Output: • Stop Notation : RECTANGLE DIAMOND PARALLELOGRAM CIRCLE Start Every algorithm process is usually starts from END And ends by
END Start Hold down the phone Hold up the phone Yes Finish Press dial button No No Dialing Talking Yes Yes No Connected Waiting Flowchart Example of Phone Calling Flowchart
Start Input Number Number % 2 1 0 Print “Odd Number” Print “Even Number” END Flowchart Example of determining odd-even number
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.
NS Diagram • Process notation : • Selection notation: • Loop notation : • WHILE • DO-WHILE Proses Kondisi Betul Salah Kondisi Belum Terpenuhi Proses Kondisi Belum Terpenuhi Proses
Hold up the phone Dialing? Press dial button Finish? Talking Hold down the phone NS Diagram Example of Phone Calling process using NS Diagram
Insert number Number % 2 Equal to 0 Equal to 1 Print “Even Number” Print “Odd Number” NS Diagram Example of NS Diagram to determine odd-even numbers
Did you know ? • The word "algorithm" comes from the name of the ninth-century Persian mathematician Mohammed al-Khowarizmi. He wrote a widely read book entitled Kitab al jabr w'al-muqabala (Rules of Restoration and Reduction) in the year of 825. This book describes many procedures for the manipulation of decimal numbers. • The word was translated into Latin in the twelve century as “Algoritmi de numero Indorum“ or “Algoritmus on the numbers of the Indians“
Referensi • Introduction to Algorithms. 2ed. Cormen. 2002. p5-13 • Introduction to Java Programming. 8ed. Liang. 2011. p29-30 • Algorithm. http://en.wikipedia.org/wiki/Algorithm • Pseudocode. http://en.wikipedia.org/wiki/Pseudocode • Flowchart. http://en.wikipedia.org/wiki/Flowchart • NS Diagram. http://en.wikipedia.org/wiki/NS_Diagram