SlideShare a Scribd company logo
Adam Mukharil Bachtiar
English Class
Informatics Engineering 2011
Algorithms and Programming
Array
Steps of the Day
Let’s Start
Definition of
Array
One Dimension
Array
Two
Dimensions
Array
Definition of Array
All About Array
BackgroundofArray
I need a program to process students data but i
want it to keep all data temporary in memory
so i can use it until the program is shut down.
WhatisArray
Data structure that saves a group of
variables which have same type.
IlustrationofArray
An Array was named bil, has integer type,
and consists of five elemens.
SUBSCRIPT / INDEX
TypesofArray
• One Dimension Array
• Two Dimensions Array
• Many Dimensions Array (i will not explain THIS!!!)
One Dimension Array
Definition and Structures of One Dimension Array
WhatisOneDimensionArray
Array that only has one subscript / index.
DeclarationofOneDimension
Array
• As variable
• As user-defined data type
• Define size of array as constant
Declaration As Variable (Algorithm)
Kamus:
NamaArray : array [1..MaxSize] of TipeData
Contoh:
Kamus:
bil : array [1..5] of integer
NamaDosen : array [1..20] of string
Pecahan : array [1..100] of real
Declaration As Variable (Pascal)
var
NamaArray : array [1..MaxSize] of TipeData;
Contoh:
var
bil : array [1..5] of integer;
NamaDosen : array [1..20] of string[30];
Pecahan : array [1..100] of real;
Declaration As User-Defined Data Type (Algorithm)
Kamus:
type
NamaArray = array [1..MaxSize] of TipeData
NamaVariabel_1:NamaArray
NamaVariabel_2:NamaArray
Declaration As User-Defined Data Type (Algorithm)
Contoh:
Kamus:
type
bil = array [1..5] of integer
bilbulat:bil
bilpositif:bil
type
NamaArray = array [1..MaxSize] of TipeData;
var
NamaVariabel_1:NamaArray;
NamaVariabel_2:NamaArray;
Declaration As User-Defined Data Type (Pascal)
Contoh:
type
bil = array [1..5] of integer;
var
bilbulat:bil;
bilpositif:bil;
Declaration As User-Defined Data Type (Pascal)
Define Size of Array As Constant (Algorithm)
Kamus:
const
MaxSize = VALUE
type
NamaArray = array [1..MaxSize] of TipeData
NamaVariabel_1:NamaArray
NamaVariabel_2:NamaArray
Contoh:
Kamus:
const
maks = 5
type
bil = array [1..maks] of integer
bilbulat:bil
Define Size of Array As Constant (Algorithm)
const
MaxSize = VALUE;
type
NamaArray : array [1..MaxSize] of TipeData;
var
NamaVariabel:NamaArray;
Define Size of Array As Constant (Pascal)
Contoh:
const
maks = 5;
type
bil = array [1..maks] of integer;
var
bilbulat:bil;
Define Size of Array As Constant (Pascal)
GetandsettheValuefrom
Array
To fill and access the value in array, call the name
of array and its subscript that you want to access
IlustrationofSettingand
GettingValueinArray
bil[1]=5  it means fill 5 in [1]
a=bil[2]  a will be filled by 1
Format of Accessing Array (Algorithm)
namaarray[indeks]  nilai
input(namaarray[indeks])
namaarray[indeks]  namaarray[indeks] + 1
output(namaarray[indeks])
Format of Accessing Array (Algorithm)
namaarray[indeks] := nilai;
readln(namaarray[indeks]);
namaarray[indeks] := namaarray[indeks] + 1;
writeln(namaarray[indeks]);
OperationinArray
• Creation
• Traversal
• Searching
• Sorting
• Destroy
ArrayCreation
• Prepare array to be accessed/processed.
Array will be filled with default value.
• For numeric array will be filled with 0 and
for alphanumeric array will be filled with ‘ ’
(Null Character)
Procedure create (output NamaVarArray:NamaArray)
{I.S: elemen array diberi harga awal agar siap digunakan}
{F.S: menghasilkan array yang siap digunakan}
Kamus:
indeks:integer
Algoritma:
for indeks  1 to maks_array do
nama_var_array[indeks] 0 {sesuaikan dengan tipe array}
endfor
EndProcedure
Array Creation (Algorithm)
procedure create (var NamaVarArray:NamaArray);
var
indeks:integer;
begin
for indeks := 1 to maks do
NamaVarArray[indeks] := 0;
end;
Array Creation (Pascal)
ArrayTraversal
The process of visiting all elements of
array one by one, from the first
element until last element.
TraversalProcesses • Fill elements array with data
• Output all elements of array
• Adding data to array
• Insert data in particular index
• Delete data in particular index
• Determine maximum and minimum data in
array
• Count mean value in array
Procedure traversal (I/O NamaVarArray:NamaArray)
{I.S: maksimum array sudah terdefinisi}
{F.S: menghasilkan array yang sudah diproses}
Kamus:
Algoritma:
for indeks  1 to maks do
{proses traversal}
endfor
Terminasi {sifatnya optional}
EndProcedure
General Form for Array Traversal (Algorithm)
procedure traversal(var NamaVarArray:NamaArray);
begin
for indeks := 1 to maks do
{proses traversal yang dipilih}
terminasi {sifatnya optional}
end;
General Form for Array Traversal (Pascal)
DestroytheArray
The process to return value of array
into default value that was given in
array creation.
Algorithm and Programming (Array)
Example of One Dimension Array (Algorithm)
1
2
3
4
5
6
7
8
9
10
11
12
13
Algoritma ArrayDasar
{I.S.: Dideklarasikan dua buah array satu dimensi}
{F.S.: Menampilkan array beserta hasil perhitungan}
Kamus:
const
maks=5
type
bil=array[1..maks] of integer
bil1,bil2:bil
i:integer
jumlah,jumlah2:integer
Example of One Dimension Array (Algorithm)
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Algoritma:
{input elemen array}
for i  1 to maks do
input(bil1[i])
endfor
for i  1 to maks do
input(bil2[i])
endfor
{output elemen array}
for i  1 to maks do
output(bil1[i])
endfor
Example of One Dimension Array (Algorithm)
28
29
30
31
32
33
34
35
37
38
39
40
for i  1 to maks do
output(bil2[i])
endfor
{proses perhitungan array}
jumlah0;
for i  1 to maks do
jumlahjumlah+bil1[i]
endfor
output(jumlah)
jumlah20;
Example of One Dimension Array (Algorithm)
41
42
43
44
for i  1 to maks do
jumlah2jumlah2+bil2[i]
endfor
output(jumlah2)
Example of One Dimension Array (Pascal)
1
2
3
4
5
6
7
8
9
10
11
12
13
program ArrayDasar;
uses crt;
const
maks=5;
type
bil=array[1..maks] of integer;
var
bil1,bil2:bil;
i:integer;
jumlah,jumlah2:integer;
Example of One Dimension Array (Pascal)
14
15
16
17
18
19
20
21
22
23
24
25
26
27
begin
{input elemen array}
for i:=1 to maks do
begin
write('Masukkan nilai ke bil 1 [',i,'] : ');
readln(bil1[i]);
end;
writeln();
for i:=1 to maks do
begin
write('Masukkan nilai ke bil 2 [',i,'] : ');
readln(bil2[i]);
end;
Example of One Dimension Array (Pascal)
28
29
30
31
32
33
34
35
37
38
39
40
{output elemen array}
for i:=1 to maks do
begin
writeln('Bil 1[',i,'] = ',bil1[i]);
end;
writeln();
for i:=1 to maks do
begin
writeln('Bil 2[',i,'] = ',bil2[i]);
end;
Example of One Dimension Array (Pascal)
41
42
43
44
45
46
47
48
49
50
51
52
53
{proses perhitungan array}
writeln();
jumlah:=0;
for i:=1 to maks do
begin
jumlah:=jumlah+bil1[i];
end;
writeln('Jumlah elemen array bil 1 = ',jumlah);
writeln();
jumlah2:=0;
for i:=1 to maks do
begin
Example of One Dimension Array (Pascal)
54
55
56
57
58
59
60
61
jumlah2:=jumlah2+bil2[i];
end;
writeln('Jumlah elemen array bil 2 = ',jumlah2);
writeln();
write('Tekan sembarang tombol untuk menutup...');
readkey();
end.
Two Dimensions Array
Definition and Structures of Two Dimensions Array
WhatisTwoDimensionsArray
Array that has two subscripts in its
declaration. It often was called matrix.
IlustrationofTwoDimensions
Array
Declaration As Variable (Algorithm)
Kamus:
NamaArray : array [1..MaxBaris,1..MaxKolom] of TipeData
Contoh:
Kamus:
matriks : array [1..5,1..5] of integer
Declaration As Variable (Pascal)
var
NamaArray : array [1..MaxBaris,1..MaxKolom] of TipeData;
Contoh:
var
matriks: array [1..5,1..5] of integer;
Declaration As User-Defined Data Type (Algorithm)
Kamus:
type
NamaArray = array [1..MaxBaris,1..MaxKolom] of TipeData
NamaVariabel_1:NamaArray
NamaVariabel_2:NamaArray
Declaration As User-Defined Data Type (Algorithm)
Contoh:
Kamus:
type
matriks = array [1..5,1..5] of integer
matriks1:matriks
type
NamaArray = array [1..MaxBaris,1..MaxKolom] of TipeData;
var
NamaVariabel_1:NamaArray;
NamaVariabel_2:NamaArray;
Declaration As User-Defined Data Type (Pascal)
Contoh:
type
matriks = array [1..5,1..5] of integer;
var
matriks1:bil;
matriks2:bil;
Declaration As User-Defined Data Type (Pascal)
Define Size of Array As Constant (Algorithm)
Kamus:
const
MaxBaris = VALUE1
MaxKolom = VALUE2
type
NamaArray = array [1..MaxBaris,1..MaxKolom] of TipeData
NamaVariabel_1:NamaArray
NamaVariabel_2:NamaArray
Contoh:
Kamus:
const
MaksBaris = 5
MaksKolom = 5
type
matriks = array [1..MaksBaris,1..MaksKolom] of integer
matriks1,matriks2:bil
Define Size of Array As Constant (Algorithm)
const
MaxBaris = VALUE1;
MaxKolom = VALUE2;
type
NamaArray : array [1..MaxBaris,1..MaxKolom] of TipeData;
var
NamaVariabel:NamaArray;
Define Size of Array As Constant (Pascal)
Contoh:
const
MaksBaris = 5;
MaksKolom = 5;
type
matriks = array [1..MaksBaris,1..MaksKolom] of integer;
var
bilbulat:bil;
Define Size of Array As Constant (Pascal)
OperationinTwoDimensions
Array
Operation in two dimensions array is same
as operation in one dimensions array.
OperationinArray
• Creation
• Traversal
• Searching
• Sorting
• Destroy
ArrayCreation
• Prepare array to be accessed/processed.
Array will be filled with default value.
• For numeric array will be filled with 0 and
for alphanumeric array will be filled with ‘ ’
(Null Character)
Procedure create (output NamaVarArray:NamaArray)
{I.S: elemen array diberi harga awal agar siap digunakan}
{F.S: menghasilkan array yang siap digunakan}
Kamus:
i,j:integer
Algoritma:
for i  1 to MaksBaris do
for j 1 to MaksKolom do
nama_var_array[i,j]  0 {sesuaikan dengan tipe array}
endfor
endfor
EndProcedure
Array Creation (Algorithm)
procedure create (var NamaVarArray:NamaArray);
var
i,j:integer;
begin
for i := 1 to MaksBaris do
begin
for j := 1 to MaksKolom do
NamaVarArray[i,j] := 0;
end;
end;
Array Creation (Pascal)
ArrayTraversal
The process of visiting all elements of
array one by one, from the first
element until last element.
TraversalProcesses • Fill elements array with data
• Output all elements of array
• Adding data to array
• Insert data in particular index
• Delete data in particular index
• Determine maximum and minimum data in
array
• Count mean value in array
Procedure traversal (I/O NamaVarArray:NamaArray)
{I.S: maksimum array sudah terdefinisi}
{F.S: menghasilkan array yang sudah diproses}
Kamus:
Algoritma:
for i  1 to MaksBaris do
for j  1 to MaksKolom do
{proses traversal}
endfor
endfor
Terminasi {sifatnya optional}
EndProcedure
General Form for Array Traversal (Algorithm)
procedure traversal(var NamaVarArray:NamaArray);
begin
for i := 1 to MaksBaris do
begin
for j := 1 to MaksKolom do
{proses traversal yang dipilih}
end;
terminasi {sifatnya optional}
end;
General Form for Array Traversal (Pascal)
DestroytheArray
The process to return value of array
into default value that was given in
array creation.
Algorithm and Programming (Array)
Example of Two Dimensions Array (Algorithm)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Algoritma ArrayDasar
{I.S.: Dideklarasikan dua buah array dua dimensi}
{F.S.: Menampilkan isi array}
Kamus:
const
MaksBaris=5
MaksKolom=5
type
bil=array[1..MaksBaris,1..MaksKolom] of integer
matriks1,matriks2:bil
i,j:integer
Example of Two Dimensions Array (Algorithm)
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Algoritma:
{input elemen array}
for i  1 to MaksBaris do
for j  1 to MaksKolom do
input(bil1[i,j])
endfor
endfor
for i  1 to MaksBaris do
for j  1 to MaksKolom do
input(bil2[i,j])
endfor
endfor
Example of Two Dimensions Array (Algorithm)
29
30
31
32
33
34
35
37
38
39
40
41
{output elemen array}
for i  1 to MaksBaris do
for j  1 to MaksKolom do
output(bil1[i,j])
endfor
endfor
for i  1 to MaksBaris do
for j  1 to MaksKolom do
output(bil1[i,j])
endfor
endfor
Example of Two Dimensions Array (Pascal)
1
2
3
4
5
6
7
8
9
10
11
12
13
program ArrayDuaDimensiDasar;
uses crt;
const
MaksBaris=3;
MaksKolom=3;
type
matriks = array[1..MaksBaris,1..MaksKolom] of
integer;
var
matriks1,matriks2:matriks;
baris,kolom:integer;
Example of Two Dimensions Array (Pascal)
14
15
16
17
18
19
20
21
22
23
24
25
26
27
begin
{input matriks}
writeln('Input Matriks Pertama');
for baris:=1 to MaksBaris do
begin
for kolom:=1 to MaksKolom do
begin
gotoxy(kolom*5+1,baris+3);
readln(matriks1[baris,kolom]);
end;
end;
writeln();
writeln('Input Matriks Kedua');
Example of Two Dimensions Array (Pascal)
28
29
30
31
32
33
34
35
37
38
39
40
for baris:=1 to MaksBaris do
begin
for kolom:=1 to MaksKolom do
begin
gotoxy(kolom*5+1,baris+9);
readln(matriks2[baris,kolom]);
end;
end;
{output matriks}
clrscr();
writeln('Output Matriks Pertama');
Example of Two Dimensions Array (Pascal)
41
42
43
44
45
46
47
48
49
50
51
52
53
for baris:=1 to MaksBaris do
begin
for kolom:=1 to MaksKolom do
begin
gotoxy(kolom*5+1,baris+3);
write(matriks1[baris,kolom]);
end;
end;
writeln();writeln();
writeln('Output Matriks Kedua');
for baris:=1 to MaksBaris do
begin
Example of Two Dimensions Array (Pascal)
54
55
56
57
58
59
60
61
62
63
64
for kolom:=1 to MaksKolom do
begin
gotoxy(kolom*5+1,baris+9);
write(matriks2[baris,kolom]);
end;
end;
writeln();
write('Tekan sembarang tombol untuk menutup...');
readkey();
end.
Contact Person:
Adam Mukharil Bachtiar
Informatics Engineering UNIKOM
Jalan Dipati Ukur Nomor. 112-114 Bandung 40132
Email: adfbipotter@gmail.com
Blog: http://adfbipotter.wordpress.com
Copyright © Adam Mukharil Bachtiar 2011

More Related Content

What's hot (20)

PPTX
Arrays in Data Structure and Algorithm
KristinaBorooah
 
PPTX
GCD of n Numbers
Saikat Roy
 
PPT
Array
PRN USM
 
PPTX
Relations in Discrete Math
Pearl Rose Cajenta
 
PDF
sparse matrix in data structure
MAHALAKSHMI P
 
PPT
sets and maps
Rajkattamuri
 
PPTX
TERMINOLOGIES OF TREE, TYPES OF TREE.pptx
KALPANAC20
 
PPTX
Complexity analysis in Algorithms
Daffodil International University
 
PDF
Structuri discrete - Curs5: Calculul propozițional
Radu Dumbrăveanu
 
PDF
DBT PU BI Lab Manual for ETL Exercise.pdf
JanakiramanS13
 
PPTX
Divide and conquer - Quick sort
Madhu Bala
 
PPT
Class and object in C++
rprajat007
 
PPTX
Lesson 3 - matrix multiplication
Jonathan Templin
 
PPTX
Elements of Dynamic Programming
Vishwajeet Shabadi
 
PDF
Java servlets
Mukesh Tekwani
 
PPT
Arrays
swathi reddy
 
PDF
Analisis Algoritma - Kelas-kelas Dasar Efisiensi Algoritma
Adam Mukharil Bachtiar
 
PPT
Analisa algoritma paralel
angga_dadox
 
PDF
[RPL2] Class Diagram dan Konsep Object Oriented (1)
rizki adam kurniawan
 
PPT
Functions in C++
Mohammed Sikander
 
Arrays in Data Structure and Algorithm
KristinaBorooah
 
GCD of n Numbers
Saikat Roy
 
Array
PRN USM
 
Relations in Discrete Math
Pearl Rose Cajenta
 
sparse matrix in data structure
MAHALAKSHMI P
 
sets and maps
Rajkattamuri
 
TERMINOLOGIES OF TREE, TYPES OF TREE.pptx
KALPANAC20
 
Complexity analysis in Algorithms
Daffodil International University
 
Structuri discrete - Curs5: Calculul propozițional
Radu Dumbrăveanu
 
DBT PU BI Lab Manual for ETL Exercise.pdf
JanakiramanS13
 
Divide and conquer - Quick sort
Madhu Bala
 
Class and object in C++
rprajat007
 
Lesson 3 - matrix multiplication
Jonathan Templin
 
Elements of Dynamic Programming
Vishwajeet Shabadi
 
Java servlets
Mukesh Tekwani
 
Arrays
swathi reddy
 
Analisis Algoritma - Kelas-kelas Dasar Efisiensi Algoritma
Adam Mukharil Bachtiar
 
Analisa algoritma paralel
angga_dadox
 
[RPL2] Class Diagram dan Konsep Object Oriented (1)
rizki adam kurniawan
 
Functions in C++
Mohammed Sikander
 

Viewers also liked (20)

PDF
Data Management (Data Mining Klasifikasi)
Adam Mukharil Bachtiar
 
PDF
Algorithm and Programming (Branching Structure)
Adam Mukharil Bachtiar
 
PDF
Algorithm and Programming (Record)
Adam Mukharil Bachtiar
 
PPSX
Algorithm and Programming (Sorting)
Adam Mukharil Bachtiar
 
PPSX
Algorithm and Programming (Searching)
Adam Mukharil Bachtiar
 
PDF
Algorithm and Programming (Introduction of Algorithms)
Adam Mukharil Bachtiar
 
PPT
Control Statements, Array, Pointer, Structures
indra Kishor
 
PDF
Pascal
Ezeodum Austin
 
PPT
Ppt lesson 12
Linda Bodrie
 
PDF
Algorithm and Programming (Looping Structure)
Adam Mukharil Bachtiar
 
PDF
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Adam Mukharil Bachtiar
 
PDF
Algorithm and Programming (Sequential Structure)
Adam Mukharil Bachtiar
 
PDF
Contoh Kasus untuk ER dan Relasional Model
Adam Mukharil Bachtiar
 
PDF
Scrum for CodeLabs
Adam Mukharil Bachtiar
 
PPTX
2- Dimensional Arrays
Education Front
 
PDF
Algorithm and Programming (Procedure and Function)
Adam Mukharil Bachtiar
 
PPTX
C# Arrays
Hock Leng PUAH
 
PDF
Data Management (Introducing of Datawarehouse)
Adam Mukharil Bachtiar
 
Data Management (Data Mining Klasifikasi)
Adam Mukharil Bachtiar
 
Algorithm and Programming (Branching Structure)
Adam Mukharil Bachtiar
 
Algorithm and Programming (Record)
Adam Mukharil Bachtiar
 
Algorithm and Programming (Sorting)
Adam Mukharil Bachtiar
 
Algorithm and Programming (Searching)
Adam Mukharil Bachtiar
 
Algorithm and Programming (Introduction of Algorithms)
Adam Mukharil Bachtiar
 
Control Statements, Array, Pointer, Structures
indra Kishor
 
Ppt lesson 12
Linda Bodrie
 
Algorithm and Programming (Looping Structure)
Adam Mukharil Bachtiar
 
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Adam Mukharil Bachtiar
 
Algorithm and Programming (Sequential Structure)
Adam Mukharil Bachtiar
 
Contoh Kasus untuk ER dan Relasional Model
Adam Mukharil Bachtiar
 
Scrum for CodeLabs
Adam Mukharil Bachtiar
 
2- Dimensional Arrays
Education Front
 
Algorithm and Programming (Procedure and Function)
Adam Mukharil Bachtiar
 
C# Arrays
Hock Leng PUAH
 
Data Management (Introducing of Datawarehouse)
Adam Mukharil Bachtiar
 
Ad

Similar to Algorithm and Programming (Array) (20)

PPTX
Computer programming 2 Lesson 13
MLG College of Learning, Inc
 
PDF
Arrays
ViniVini48
 
PPT
07 Arrays
maznabili
 
PDF
Lecture 2.8 Arrays.pdf
MianSaeedAkbar1
 
PPSX
C Programming : Arrays
Gagan Deep
 
PPT
Basics of Data structure using C describing basics concepts
shanthidl1
 
PDF
Arrays
Steven Wallach
 
PPTX
Data structure array
MajidHamidAli
 
PPT
Lec 25 - arrays-strings
Princess Sam
 
PPT
ARRAYS.ppt
soniya555961
 
PDF
SPL 10 | One Dimensional Array in C
Mohammad Imam Hossain
 
PDF
Array and its types and it's implemented programming Final.pdf
ajajkhan16
 
PDF
Java arrays (1)
Liza Abello
 
PPTX
object oriented programing in python and pip
LakshmiMarineni
 
PPT
2 arrays
trixiacruz
 
PPTX
Programming in c Arrays
janani thirupathi
 
PPTX
Unit 6. Arrays
Ashim Lamichhane
 
PPTX
ch 7 single dimension array in oop .pptx
nilampatoliya
 
Computer programming 2 Lesson 13
MLG College of Learning, Inc
 
Arrays
ViniVini48
 
07 Arrays
maznabili
 
Lecture 2.8 Arrays.pdf
MianSaeedAkbar1
 
C Programming : Arrays
Gagan Deep
 
Basics of Data structure using C describing basics concepts
shanthidl1
 
Data structure array
MajidHamidAli
 
Lec 25 - arrays-strings
Princess Sam
 
ARRAYS.ppt
soniya555961
 
SPL 10 | One Dimensional Array in C
Mohammad Imam Hossain
 
Array and its types and it's implemented programming Final.pdf
ajajkhan16
 
Java arrays (1)
Liza Abello
 
object oriented programing in python and pip
LakshmiMarineni
 
2 arrays
trixiacruz
 
Programming in c Arrays
janani thirupathi
 
Unit 6. Arrays
Ashim Lamichhane
 
ch 7 single dimension array in oop .pptx
nilampatoliya
 
Ad

More from Adam Mukharil Bachtiar (20)

PDF
Materi 8 - Data Mining Association Rule.pdf
Adam Mukharil Bachtiar
 
PDF
Clean Code - Formatting Code
Adam Mukharil Bachtiar
 
PDF
Clean Code - Clean Comments
Adam Mukharil Bachtiar
 
PDF
Clean Method
Adam Mukharil Bachtiar
 
PDF
Clean Code and Design Pattern - Meaningful Names
Adam Mukharil Bachtiar
 
PDF
Model Driven Software Development
Adam Mukharil Bachtiar
 
PDF
Scrum: How to Implement
Adam Mukharil Bachtiar
 
PDF
Pengujian Perangkat Lunak
Adam Mukharil Bachtiar
 
PDF
Data Mining Clustering
Adam Mukharil Bachtiar
 
PPTX
Data Mining Klasifikasi (Updated 30 Desember 2020)
Adam Mukharil Bachtiar
 
PDF
Analisis Algoritma - Strategi Algoritma Dynamic Programming
Adam Mukharil Bachtiar
 
PDF
Analisis Algoritma - Strategi Algoritma Divide and Conquer
Adam Mukharil Bachtiar
 
PDF
Analisis Algoritma - Strategi Algoritma Greedy
Adam Mukharil Bachtiar
 
PDF
Analisis Algoritma - Penerapan Strategi Algoritma Brute Force
Adam Mukharil Bachtiar
 
PDF
Analisis Algoritma - Strategi Algoritma Brute Force
Adam Mukharil Bachtiar
 
PDF
Analisis Algoritma - Teorema Notasi Asimptotik
Adam Mukharil Bachtiar
 
PDF
Analisis Algoritma - Notasi Asimptotik
Adam Mukharil Bachtiar
 
PDF
Activity Diagram
Adam Mukharil Bachtiar
 
PDF
UML dan Use Case View
Adam Mukharil Bachtiar
 
PDF
Analisis Algoritma - Langkah Desain Algoritma
Adam Mukharil Bachtiar
 
Materi 8 - Data Mining Association Rule.pdf
Adam Mukharil Bachtiar
 
Clean Code - Formatting Code
Adam Mukharil Bachtiar
 
Clean Code - Clean Comments
Adam Mukharil Bachtiar
 
Clean Code and Design Pattern - Meaningful Names
Adam Mukharil Bachtiar
 
Model Driven Software Development
Adam Mukharil Bachtiar
 
Scrum: How to Implement
Adam Mukharil Bachtiar
 
Pengujian Perangkat Lunak
Adam Mukharil Bachtiar
 
Data Mining Clustering
Adam Mukharil Bachtiar
 
Data Mining Klasifikasi (Updated 30 Desember 2020)
Adam Mukharil Bachtiar
 
Analisis Algoritma - Strategi Algoritma Dynamic Programming
Adam Mukharil Bachtiar
 
Analisis Algoritma - Strategi Algoritma Divide and Conquer
Adam Mukharil Bachtiar
 
Analisis Algoritma - Strategi Algoritma Greedy
Adam Mukharil Bachtiar
 
Analisis Algoritma - Penerapan Strategi Algoritma Brute Force
Adam Mukharil Bachtiar
 
Analisis Algoritma - Strategi Algoritma Brute Force
Adam Mukharil Bachtiar
 
Analisis Algoritma - Teorema Notasi Asimptotik
Adam Mukharil Bachtiar
 
Analisis Algoritma - Notasi Asimptotik
Adam Mukharil Bachtiar
 
Activity Diagram
Adam Mukharil Bachtiar
 
UML dan Use Case View
Adam Mukharil Bachtiar
 
Analisis Algoritma - Langkah Desain Algoritma
Adam Mukharil Bachtiar
 

Recently uploaded (20)

PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PPTX
Build a Custom Agent for Agentic Testing.pptx
klpathrudu
 
PPTX
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PDF
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PPTX
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
NSF Converter Simplified: From Complexity to Clarity
Johnsena Crook
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PDF
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
PDF
Simplify React app login with asgardeo-sdk
vaibhav289687
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PDF
ERP Consulting Services and Solutions by Contetra Pvt Ltd
jayjani123
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PPTX
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
Build a Custom Agent for Agentic Testing.pptx
klpathrudu
 
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
NSF Converter Simplified: From Complexity to Clarity
Johnsena Crook
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
Simplify React app login with asgardeo-sdk
vaibhav289687
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
ERP Consulting Services and Solutions by Contetra Pvt Ltd
jayjani123
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 

Algorithm and Programming (Array)

  • 1. Adam Mukharil Bachtiar English Class Informatics Engineering 2011 Algorithms and Programming Array
  • 2. Steps of the Day Let’s Start Definition of Array One Dimension Array Two Dimensions Array
  • 4. BackgroundofArray I need a program to process students data but i want it to keep all data temporary in memory so i can use it until the program is shut down.
  • 5. WhatisArray Data structure that saves a group of variables which have same type.
  • 6. IlustrationofArray An Array was named bil, has integer type, and consists of five elemens. SUBSCRIPT / INDEX
  • 7. TypesofArray • One Dimension Array • Two Dimensions Array • Many Dimensions Array (i will not explain THIS!!!)
  • 8. One Dimension Array Definition and Structures of One Dimension Array
  • 9. WhatisOneDimensionArray Array that only has one subscript / index.
  • 10. DeclarationofOneDimension Array • As variable • As user-defined data type • Define size of array as constant
  • 11. Declaration As Variable (Algorithm) Kamus: NamaArray : array [1..MaxSize] of TipeData Contoh: Kamus: bil : array [1..5] of integer NamaDosen : array [1..20] of string Pecahan : array [1..100] of real
  • 12. Declaration As Variable (Pascal) var NamaArray : array [1..MaxSize] of TipeData; Contoh: var bil : array [1..5] of integer; NamaDosen : array [1..20] of string[30]; Pecahan : array [1..100] of real;
  • 13. Declaration As User-Defined Data Type (Algorithm) Kamus: type NamaArray = array [1..MaxSize] of TipeData NamaVariabel_1:NamaArray NamaVariabel_2:NamaArray
  • 14. Declaration As User-Defined Data Type (Algorithm) Contoh: Kamus: type bil = array [1..5] of integer bilbulat:bil bilpositif:bil
  • 15. type NamaArray = array [1..MaxSize] of TipeData; var NamaVariabel_1:NamaArray; NamaVariabel_2:NamaArray; Declaration As User-Defined Data Type (Pascal)
  • 16. Contoh: type bil = array [1..5] of integer; var bilbulat:bil; bilpositif:bil; Declaration As User-Defined Data Type (Pascal)
  • 17. Define Size of Array As Constant (Algorithm) Kamus: const MaxSize = VALUE type NamaArray = array [1..MaxSize] of TipeData NamaVariabel_1:NamaArray NamaVariabel_2:NamaArray
  • 18. Contoh: Kamus: const maks = 5 type bil = array [1..maks] of integer bilbulat:bil Define Size of Array As Constant (Algorithm)
  • 19. const MaxSize = VALUE; type NamaArray : array [1..MaxSize] of TipeData; var NamaVariabel:NamaArray; Define Size of Array As Constant (Pascal)
  • 20. Contoh: const maks = 5; type bil = array [1..maks] of integer; var bilbulat:bil; Define Size of Array As Constant (Pascal)
  • 21. GetandsettheValuefrom Array To fill and access the value in array, call the name of array and its subscript that you want to access
  • 22. IlustrationofSettingand GettingValueinArray bil[1]=5  it means fill 5 in [1] a=bil[2]  a will be filled by 1
  • 23. Format of Accessing Array (Algorithm) namaarray[indeks]  nilai input(namaarray[indeks]) namaarray[indeks]  namaarray[indeks] + 1 output(namaarray[indeks])
  • 24. Format of Accessing Array (Algorithm) namaarray[indeks] := nilai; readln(namaarray[indeks]); namaarray[indeks] := namaarray[indeks] + 1; writeln(namaarray[indeks]);
  • 25. OperationinArray • Creation • Traversal • Searching • Sorting • Destroy
  • 26. ArrayCreation • Prepare array to be accessed/processed. Array will be filled with default value. • For numeric array will be filled with 0 and for alphanumeric array will be filled with ‘ ’ (Null Character)
  • 27. Procedure create (output NamaVarArray:NamaArray) {I.S: elemen array diberi harga awal agar siap digunakan} {F.S: menghasilkan array yang siap digunakan} Kamus: indeks:integer Algoritma: for indeks  1 to maks_array do nama_var_array[indeks] 0 {sesuaikan dengan tipe array} endfor EndProcedure Array Creation (Algorithm)
  • 28. procedure create (var NamaVarArray:NamaArray); var indeks:integer; begin for indeks := 1 to maks do NamaVarArray[indeks] := 0; end; Array Creation (Pascal)
  • 29. ArrayTraversal The process of visiting all elements of array one by one, from the first element until last element.
  • 30. TraversalProcesses • Fill elements array with data • Output all elements of array • Adding data to array • Insert data in particular index • Delete data in particular index • Determine maximum and minimum data in array • Count mean value in array
  • 31. Procedure traversal (I/O NamaVarArray:NamaArray) {I.S: maksimum array sudah terdefinisi} {F.S: menghasilkan array yang sudah diproses} Kamus: Algoritma: for indeks  1 to maks do {proses traversal} endfor Terminasi {sifatnya optional} EndProcedure General Form for Array Traversal (Algorithm)
  • 32. procedure traversal(var NamaVarArray:NamaArray); begin for indeks := 1 to maks do {proses traversal yang dipilih} terminasi {sifatnya optional} end; General Form for Array Traversal (Pascal)
  • 33. DestroytheArray The process to return value of array into default value that was given in array creation.
  • 35. Example of One Dimension Array (Algorithm) 1 2 3 4 5 6 7 8 9 10 11 12 13 Algoritma ArrayDasar {I.S.: Dideklarasikan dua buah array satu dimensi} {F.S.: Menampilkan array beserta hasil perhitungan} Kamus: const maks=5 type bil=array[1..maks] of integer bil1,bil2:bil i:integer jumlah,jumlah2:integer
  • 36. Example of One Dimension Array (Algorithm) 14 15 16 17 18 19 20 21 22 23 24 25 26 27 Algoritma: {input elemen array} for i  1 to maks do input(bil1[i]) endfor for i  1 to maks do input(bil2[i]) endfor {output elemen array} for i  1 to maks do output(bil1[i]) endfor
  • 37. Example of One Dimension Array (Algorithm) 28 29 30 31 32 33 34 35 37 38 39 40 for i  1 to maks do output(bil2[i]) endfor {proses perhitungan array} jumlah0; for i  1 to maks do jumlahjumlah+bil1[i] endfor output(jumlah) jumlah20;
  • 38. Example of One Dimension Array (Algorithm) 41 42 43 44 for i  1 to maks do jumlah2jumlah2+bil2[i] endfor output(jumlah2)
  • 39. Example of One Dimension Array (Pascal) 1 2 3 4 5 6 7 8 9 10 11 12 13 program ArrayDasar; uses crt; const maks=5; type bil=array[1..maks] of integer; var bil1,bil2:bil; i:integer; jumlah,jumlah2:integer;
  • 40. Example of One Dimension Array (Pascal) 14 15 16 17 18 19 20 21 22 23 24 25 26 27 begin {input elemen array} for i:=1 to maks do begin write('Masukkan nilai ke bil 1 [',i,'] : '); readln(bil1[i]); end; writeln(); for i:=1 to maks do begin write('Masukkan nilai ke bil 2 [',i,'] : '); readln(bil2[i]); end;
  • 41. Example of One Dimension Array (Pascal) 28 29 30 31 32 33 34 35 37 38 39 40 {output elemen array} for i:=1 to maks do begin writeln('Bil 1[',i,'] = ',bil1[i]); end; writeln(); for i:=1 to maks do begin writeln('Bil 2[',i,'] = ',bil2[i]); end;
  • 42. Example of One Dimension Array (Pascal) 41 42 43 44 45 46 47 48 49 50 51 52 53 {proses perhitungan array} writeln(); jumlah:=0; for i:=1 to maks do begin jumlah:=jumlah+bil1[i]; end; writeln('Jumlah elemen array bil 1 = ',jumlah); writeln(); jumlah2:=0; for i:=1 to maks do begin
  • 43. Example of One Dimension Array (Pascal) 54 55 56 57 58 59 60 61 jumlah2:=jumlah2+bil2[i]; end; writeln('Jumlah elemen array bil 2 = ',jumlah2); writeln(); write('Tekan sembarang tombol untuk menutup...'); readkey(); end.
  • 44. Two Dimensions Array Definition and Structures of Two Dimensions Array
  • 45. WhatisTwoDimensionsArray Array that has two subscripts in its declaration. It often was called matrix.
  • 47. Declaration As Variable (Algorithm) Kamus: NamaArray : array [1..MaxBaris,1..MaxKolom] of TipeData Contoh: Kamus: matriks : array [1..5,1..5] of integer
  • 48. Declaration As Variable (Pascal) var NamaArray : array [1..MaxBaris,1..MaxKolom] of TipeData; Contoh: var matriks: array [1..5,1..5] of integer;
  • 49. Declaration As User-Defined Data Type (Algorithm) Kamus: type NamaArray = array [1..MaxBaris,1..MaxKolom] of TipeData NamaVariabel_1:NamaArray NamaVariabel_2:NamaArray
  • 50. Declaration As User-Defined Data Type (Algorithm) Contoh: Kamus: type matriks = array [1..5,1..5] of integer matriks1:matriks
  • 51. type NamaArray = array [1..MaxBaris,1..MaxKolom] of TipeData; var NamaVariabel_1:NamaArray; NamaVariabel_2:NamaArray; Declaration As User-Defined Data Type (Pascal)
  • 52. Contoh: type matriks = array [1..5,1..5] of integer; var matriks1:bil; matriks2:bil; Declaration As User-Defined Data Type (Pascal)
  • 53. Define Size of Array As Constant (Algorithm) Kamus: const MaxBaris = VALUE1 MaxKolom = VALUE2 type NamaArray = array [1..MaxBaris,1..MaxKolom] of TipeData NamaVariabel_1:NamaArray NamaVariabel_2:NamaArray
  • 54. Contoh: Kamus: const MaksBaris = 5 MaksKolom = 5 type matriks = array [1..MaksBaris,1..MaksKolom] of integer matriks1,matriks2:bil Define Size of Array As Constant (Algorithm)
  • 55. const MaxBaris = VALUE1; MaxKolom = VALUE2; type NamaArray : array [1..MaxBaris,1..MaxKolom] of TipeData; var NamaVariabel:NamaArray; Define Size of Array As Constant (Pascal)
  • 56. Contoh: const MaksBaris = 5; MaksKolom = 5; type matriks = array [1..MaksBaris,1..MaksKolom] of integer; var bilbulat:bil; Define Size of Array As Constant (Pascal)
  • 57. OperationinTwoDimensions Array Operation in two dimensions array is same as operation in one dimensions array.
  • 58. OperationinArray • Creation • Traversal • Searching • Sorting • Destroy
  • 59. ArrayCreation • Prepare array to be accessed/processed. Array will be filled with default value. • For numeric array will be filled with 0 and for alphanumeric array will be filled with ‘ ’ (Null Character)
  • 60. Procedure create (output NamaVarArray:NamaArray) {I.S: elemen array diberi harga awal agar siap digunakan} {F.S: menghasilkan array yang siap digunakan} Kamus: i,j:integer Algoritma: for i  1 to MaksBaris do for j 1 to MaksKolom do nama_var_array[i,j]  0 {sesuaikan dengan tipe array} endfor endfor EndProcedure Array Creation (Algorithm)
  • 61. procedure create (var NamaVarArray:NamaArray); var i,j:integer; begin for i := 1 to MaksBaris do begin for j := 1 to MaksKolom do NamaVarArray[i,j] := 0; end; end; Array Creation (Pascal)
  • 62. ArrayTraversal The process of visiting all elements of array one by one, from the first element until last element.
  • 63. TraversalProcesses • Fill elements array with data • Output all elements of array • Adding data to array • Insert data in particular index • Delete data in particular index • Determine maximum and minimum data in array • Count mean value in array
  • 64. Procedure traversal (I/O NamaVarArray:NamaArray) {I.S: maksimum array sudah terdefinisi} {F.S: menghasilkan array yang sudah diproses} Kamus: Algoritma: for i  1 to MaksBaris do for j  1 to MaksKolom do {proses traversal} endfor endfor Terminasi {sifatnya optional} EndProcedure General Form for Array Traversal (Algorithm)
  • 65. procedure traversal(var NamaVarArray:NamaArray); begin for i := 1 to MaksBaris do begin for j := 1 to MaksKolom do {proses traversal yang dipilih} end; terminasi {sifatnya optional} end; General Form for Array Traversal (Pascal)
  • 66. DestroytheArray The process to return value of array into default value that was given in array creation.
  • 68. Example of Two Dimensions Array (Algorithm) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Algoritma ArrayDasar {I.S.: Dideklarasikan dua buah array dua dimensi} {F.S.: Menampilkan isi array} Kamus: const MaksBaris=5 MaksKolom=5 type bil=array[1..MaksBaris,1..MaksKolom] of integer matriks1,matriks2:bil i,j:integer
  • 69. Example of Two Dimensions Array (Algorithm) 15 16 17 18 19 20 21 22 23 24 25 26 27 28 Algoritma: {input elemen array} for i  1 to MaksBaris do for j  1 to MaksKolom do input(bil1[i,j]) endfor endfor for i  1 to MaksBaris do for j  1 to MaksKolom do input(bil2[i,j]) endfor endfor
  • 70. Example of Two Dimensions Array (Algorithm) 29 30 31 32 33 34 35 37 38 39 40 41 {output elemen array} for i  1 to MaksBaris do for j  1 to MaksKolom do output(bil1[i,j]) endfor endfor for i  1 to MaksBaris do for j  1 to MaksKolom do output(bil1[i,j]) endfor endfor
  • 71. Example of Two Dimensions Array (Pascal) 1 2 3 4 5 6 7 8 9 10 11 12 13 program ArrayDuaDimensiDasar; uses crt; const MaksBaris=3; MaksKolom=3; type matriks = array[1..MaksBaris,1..MaksKolom] of integer; var matriks1,matriks2:matriks; baris,kolom:integer;
  • 72. Example of Two Dimensions Array (Pascal) 14 15 16 17 18 19 20 21 22 23 24 25 26 27 begin {input matriks} writeln('Input Matriks Pertama'); for baris:=1 to MaksBaris do begin for kolom:=1 to MaksKolom do begin gotoxy(kolom*5+1,baris+3); readln(matriks1[baris,kolom]); end; end; writeln(); writeln('Input Matriks Kedua');
  • 73. Example of Two Dimensions Array (Pascal) 28 29 30 31 32 33 34 35 37 38 39 40 for baris:=1 to MaksBaris do begin for kolom:=1 to MaksKolom do begin gotoxy(kolom*5+1,baris+9); readln(matriks2[baris,kolom]); end; end; {output matriks} clrscr(); writeln('Output Matriks Pertama');
  • 74. Example of Two Dimensions Array (Pascal) 41 42 43 44 45 46 47 48 49 50 51 52 53 for baris:=1 to MaksBaris do begin for kolom:=1 to MaksKolom do begin gotoxy(kolom*5+1,baris+3); write(matriks1[baris,kolom]); end; end; writeln();writeln(); writeln('Output Matriks Kedua'); for baris:=1 to MaksBaris do begin
  • 75. Example of Two Dimensions Array (Pascal) 54 55 56 57 58 59 60 61 62 63 64 for kolom:=1 to MaksKolom do begin gotoxy(kolom*5+1,baris+9); write(matriks2[baris,kolom]); end; end; writeln(); write('Tekan sembarang tombol untuk menutup...'); readkey(); end.
  • 76. Contact Person: Adam Mukharil Bachtiar Informatics Engineering UNIKOM Jalan Dipati Ukur Nomor. 112-114 Bandung 40132 Email: [email protected] Blog: http://adfbipotter.wordpress.com Copyright © Adam Mukharil Bachtiar 2011