By :
M. Alif Muwafiq B
 Sebagai suatu kumpulan data yang seolah
olah ada data yang diletakkan di atas data
yang lain.
 Kita bisa manambah data, menghapus data,
lewat ujung yang sama  yang disebut TOP
OF STACK.
2
3
4
5
6
1
7
8
A
S
C
A
L
P TOP of STACK
TOP of STACK
TOP of STACK
TOP of STACK
TOP of STACK
TOP of STACK
MAX
PUSH
CREATE
cek apakah stack penuh ?
procedure push (e: char); {mengisi isi stack}
Begin
if top <> max then
begin
inc(top);
stack [top] := e ;
pushanim;
end else
begin {peringatan jika stack telah kosong}
gotoxy (1,7); write ('STACK TELAH PENUH');
readkey;
gotoxy (1,7); clreol;
end;
end;
PUSH
CREATE
POP
2
3
4
5
6
1
7
8
A
S
C
A
L
P TOP of STACK
TOP of STACK
TOP of STACK
TOP of STACK
TOP of STACK
TOP of STACK
MAX
cek apakah stack kosong ?
procedure pop(e:char); {mengeluarkan isi stack}
begin
if top <> 0 then
begin
e := stack [top];
dec (top);
popanim(e);
end else
begin {peringatan jika stack telah kosong}
gotoxy (1,7); write ('STACK TELAH KOSONG');
readkey;
gotoxy (1,7); clreol;
end;
end;
POP
EMPTY /
TOP = 0
Stack

Stack

  • 1.
    By : M. AlifMuwafiq B
  • 2.
     Sebagai suatukumpulan data yang seolah olah ada data yang diletakkan di atas data yang lain.  Kita bisa manambah data, menghapus data, lewat ujung yang sama  yang disebut TOP OF STACK.
  • 3.
    2 3 4 5 6 1 7 8 A S C A L P TOP ofSTACK TOP of STACK TOP of STACK TOP of STACK TOP of STACK TOP of STACK MAX PUSH CREATE cek apakah stack penuh ? procedure push (e: char); {mengisi isi stack} Begin if top <> max then begin inc(top); stack [top] := e ; pushanim; end else begin {peringatan jika stack telah kosong} gotoxy (1,7); write ('STACK TELAH PENUH'); readkey; gotoxy (1,7); clreol; end; end; PUSH CREATE
  • 4.
    POP 2 3 4 5 6 1 7 8 A S C A L P TOP ofSTACK TOP of STACK TOP of STACK TOP of STACK TOP of STACK TOP of STACK MAX cek apakah stack kosong ? procedure pop(e:char); {mengeluarkan isi stack} begin if top <> 0 then begin e := stack [top]; dec (top); popanim(e); end else begin {peringatan jika stack telah kosong} gotoxy (1,7); write ('STACK TELAH KOSONG'); readkey; gotoxy (1,7); clreol; end; end; POP EMPTY / TOP = 0