Analisis Algoritma
Procedure push_stack_array (1/0 top : integer,
1/0 stack : larik_stack, input elemen : integer)
Kamus : {prototype}
Function penuh
(input top: integer)→bolean
Algiritma :
If (not
penuh(top)) then
Input
(elemen)
Top ← top + 1
Stack (top) ← elemen
Else
Output
(“stack penuh”)
Endif
Endprocedure
a. Oprasi pengisian
sintaks
|
jumlah
|
Input (elemen)
|
1
|
Top ← top + 1
|
1
|
Stack (top) ← elemen
|
1
|
total
|
n
|
b. Oprasi penjumlahan
sintaks
|
jumlah
|
Top ← top + 1
|
1
|
total
|
1
|
Total waktu = T1 + T2
= 3a + b