Upload
muhammad-andri
View
16
Download
0
Embed Size (px)
Citation preview
Algorithm and Programming IWeek 1
Anggina Primanita, [email protected]
slide adapted from Algoritma Pemrograman-I: Drs. Megah Mulya, M.T & Samsuryadi, M.Kom
Subject at glance
Algorithm and Programming I
15 meetings
Meetings will be carried out in both bahasa Indonesia and English
subsequent slides can be accessed at :http://is.gd/AlPro1_IF1A
Subject at glance
At the end of this subject, you will be able to: distinguish various algorithm and programming
notations and programing languages choose correct usages of data types distinguish and using correct control structures distinguish correct usages between procedure and
function in an algorithm. using pointers in algorithm and program
development
Subject at glance
Textbooks: Algoritma dan Pemrograman dalam Bahasa
Pascal dan C (Rinaldi Munir) Pemrograman C++: Membahas Pemrograman
Berorientasi Objek Menggunakan Turbo C++ dan Borland C++ (Abdul Kadir Heriyanto)
Today’s coverage
Definitions of Programming
Definitions of Algorithm
Terms in Algorithm and Programming
Introduction
Computers is used to help human solve their problem
But to get computer to solve your problem… can be a problem :/ it can’t be solve as it is
computer is a machine, therefore it only knows machine language
There should be a language that is known to both human and computer the problem is represented as a “program”
Programming: Introduction
Programming… has to based on a full comprehension over a
problem, analysis, and synthesis. It’s not a trial and error process
Programming: Paradigm
Procedural/Structured/Imperative
Functional
Declarative/Predictive/Logical
Object Oriented
Programming: Language
Procedural: Algol, Pascal, Fortran, Basic, Cobol, C
Functional: LOGO, APL, LISP
Declarative/Predictive/Logical: Prolog
Object Oriented pure OOP: Smalltalk, Eifel, Java hybrid: C++, Object Pascal
Programming: on Learning
Learning programming language won’t be the same as learning how to program learning programming language is related to
syntaxes, instructions, and how to use compiler on a computer
learning how to program is related to problem solving strategies and how to express it into a structured notation
Programming: Logics
Is similar to computers’
Input device Output Device
CPU
ProcessorControl Unit
ALU
Input OutputProcess
Programming: How it works
Programming languages is ‘translated’ into machine languages
Editor#include <stdio.h>void main(){ printf("Hello World");}
…..mov ah,9 mov dx,offset hello_message int 21h ….
1 2 3 4 5 7 8 96
11 12 13 14 15 17 18 1916
21 22 23 24 25 27 28 2926
data
program
1 2 3 4 5 7 8 96
11 12 13 14 15 17 18 1916
21 22 23 24 25 27 28 2926
M O V A H , 9
4 5 3
MACHINE LANGUAGE
PROCESSORM
EM
OR
Y ALU
A BM O V
hi lvl language assembler language
compiled
you need to find a way to clearly define a problem
Problem
Algorithms
High level language
Assembly language
Execution
• C• C++• Java• Basic
Compiler: - Turbo C++- Borland C++ Builder
- Turbo Pascal- Turbo Basic- Visual Basic
Interpreter:- Basica- Dbase III++- Java
Algorithm: Introduction
Definitions logical steps to be taken to solve a problem domain According to Kamus Besar Bahasa Indonesia
“Algoritma adalah urutan logis pengambilan putusan untuk pemecahan masalah”
Algorithm: Origin
First implemented on Webster Dictionary in 1957, the word ‘Algorism’ is derived from Abu Ja’far Muhammad ibnu Musa al-Khuwarizmi. The founder of this field of study
Algorithm: Important aspects
Finiteness it has to stop at one point
Definiteness it has to be well defined
Input it can have one ore more inputs before executed
Output it can have one or more outputs
Effectiveness it has to be effective
Algorithm: in writing
Can be expressed in 3 ways: natural language
daily conversational language can be ambiguous
flow chart visually descriptive things can get complicated
pseudo-code almost identical to programming language not everyone can understand..
Algorithm: Even vs Odd
in Natural language Define a place in computer storage to keep the
number; namely x Read user’s input number If x divided by 2 and its remainder is 0, the word
‘even’ will be displayed on the screenotherwise, the word ‘odd’ will be displayed on
the screen
Start
int X
Read X
x%2 = 0 ? display “odd”
display “even”
End
no
yes
Algorithm: Even vs Odd
as Flowchart