Double Linked List - PowerPoint PPT Presentation

Loading...

PPT – Double Linked List PowerPoint presentation | free to download - id: 4426c8-NzU5M



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

Double Linked List

Description:

Double Linked List Entin Martiana Operasi Double Linked List Membangun Double Linked List Membaca list, dalam dua arah. Mencari simpul tertentu Menghapus simpul ... – PowerPoint PPT presentation

Number of Views:76
Avg rating:3.0/5.0
Slides: 68
Provided by: EEP8
Category:
Tags: double | linked | list

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: Double Linked List


1
Double Linked List
  • Entin Martiana

2
Operasi Double Linked List
  • Membangun Double Linked List
  • Membaca list, dalam dua arah.
  • Mencari simpul tertentu
  • Menghapus simpul tertentu
  • Menyisipkan sebagai simpul pertama
  • Menyisipkan simpul di tengah

3
Double Linked List
0
1
2
3
4
tail
head
4
Deklarasi
  • struct simpul
  • char nama25
  • int nrp
  • struct simpul before
  • struct simpul next
  • struct simpul baru

simpul
nama nrp
data
before
pointer yg menunjuk simpul sebelumnya
pointer yg menunjuk simpul berikutnya
next
5
Membangun Linked List
  • Apa yang harus dilakukan?
  • Deklarasi
  • Memory allocation
  • Mengisi data
  • Menyiapkan untuk dihubungkan dengan data baru
    berikutnya

6
Bagaimana?
baru
  • struct simpul baru
  • baru(struct simpul)malloc(sizeof(struct
    simpul))
  • printf("Nama ")scanf("s",baru-gtnama)
  • printf("NRP ")scanf("d",baru-gtnrp)
  • if(pertama)
  • baru-gtbeforeNULL

nama1 nrp1
before
next
baru
nama1 nrp1
before
NULL
next
7
Bagaimana?
baru
  • struct simpul baru
  • baru(struct simpul)malloc(sizeof(struct
    simpul))
  • printf("Nama ")scanf("s",baru-gtnama)
  • printf("NRP ")scanf("d",baru-gtnrp)
  • if(pertama)
  • baru-gtbeforeNULL
  • baru-gtnextNULL

nama1 nrp1
before
next
baru
nama1 nrp1
before
NULL
next
NULL
8
Bagaimana?
baru
  • struct simpul baru
  • baru(struct simpul)malloc(sizeof(struct
    simpul))
  • printf("Nama ")scanf("s",baru-gtnama)
  • printf("NRP ")scanf("d",baru-gtnrp)
  • if(pertama)
  • baru-gtbeforeNULL
  • baru-gtnextNULL
  • headbaru

nama1 nrp1
before
next
head
baru
nama1 nrp1
before
NULL
next
NULL
9
Bagaimana?
baru
  • struct simpul baru
  • baru(struct simpul)malloc(sizeof(struct
    simpul))
  • printf("Nama ")scanf("s",baru-gtnama)
  • printf("NRP ")scanf("d",baru-gtnrp)
  • if(pertama)
  • baru-gtbeforeNULL
  • baru-gtnextNULL
  • head baru
  • tail baru

nama1 nrp1
before
next
head
baru
tail
nama1 nrp1
before
NULL
next
NULL
10
Selanjutnya
baru
  • baru(struct simpul)malloc(sizeof(struct
    simpul))
  • printf("Nama ")scanf("s",baru-gtnama)
  • printf("NRP ")scanf("d",baru-gtnrp)
  • if(bukanpertama)
  • baru-gtnextNULL

nama2 nrp2
before
next
baru
tail
head
nama2 nrp2
nama1 nrp1
before
before
NULL
next
next
NULL
NULL
11
Selanjutnya
baru
  • baru(struct simpul)malloc(sizeof(struct
    simpul))
  • printf("Nama ")scanf("s",baru-gtnama)
  • printf("NRP ")scanf("d",baru-gtnrp)
  • if(bukanpertama)
  • baru-gtnextNULL
  • tail-gtnextbaru

nama2 nrp2
before
next
baru
tail
head
nama2 nrp2
nama1 nrp1
before
before
NULL
next
next
NULL
12
Selanjutnya
baru
  • baru(struct simpul)malloc(sizeof(struct
    simpul))
  • printf("Nama ")scanf("s",baru-gtnama)
  • printf("NRP ")scanf("d",baru-gtnrp)
  • if(bukanpertama)
  • baru-gtnextNULL
  • tail-gtnextbaru
  • baru-gtbeforetail

nama2 nrp2
before
next
baru
tail
head
nama2 nrp2
nama1 nrp1
before
before
NULL
next
next
NULL
13
Selanjutnya
baru
  • baru(struct simpul)malloc(sizeof(struct
    simpul))
  • printf("Nama ")scanf("s",baru-gtnama)
  • printf("NRP ")scanf("d",baru-gtnrp)
  • if(jltgt0)
  • baru-gtnextNULL
  • tail-gtnextbaru
  • baru-gtbeforetail
  • tailbaru

nama2 nrp2
before
next
tail
head
nama2 nrp2
nama1 nrp1
before
before
NULL
next
next
NULL
14
Sampai iterasi keempat
tail
head
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
15
Membaca (FIFO)
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
bacaFIFO
bacaFIFO head
16
Membaca (FIFO)
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
bacaFIFO
while (bacaFIFO!NULL) // fungsi
menampilkan bacaFIFO bacaFIFO -gt next
17
Membaca (FIFO)
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
bacaFIFO
while (bacaFIFO!NULL) // fungsi
menampilkan bacaFIFO bacaFIFO -gt next
18
Membaca (FIFO)
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
bacaFIFO
while (bacaFIFO!NULL) // fungsi
menampilkan bacaFIFO bacaFIFO -gt next
19
Membaca (FIFO)
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
bacaFIFO
while (bacaFIFOltgtNULL) // fungsi
menampilkan bacaFIFO bacaFIFO -gt next
20
Membaca (LIFO)
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
bacaLIFO
bacaLIFO tail
21
Membaca (LIFO)
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
bacaLIFO
while (bacaLIFOltgtNULL) // fungsi
menampilkan bacaLIFO bacaLIFO -gt before
22
Membaca (LIFO)
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
bacaLIFO
while (bacaLIFOltgtNULL) // fungsi
menampilkan bacaLIFO bacaLIFO -gt before
23
Membaca (LIFO)
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
bacaLIFO
while (bacaLIFOltgtNULL) // fungsi
menampilkan bacaLIFO bacaLIFO -gt before
24
Membaca (LIFO)
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
bacaLIFO
while (bacaLIFOltgtNULL) // fungsi
menampilkan bacaLIFO bacaLIFO -gt before
25
Mencari Simpul Tertentu
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
cari
cari head
26
Mencari Simpul Tertentu
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
cari
while (cari-gtnama!nama3) cari cari -gt next
27
Mencari Simpul Tertentu
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
cari
while (cari-gtnama!nama3) cari cari -gt next
28
Mencari Simpul Tertentu
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
cari
while (cari-gtnama!nama3) cari cari -gt next
29
Menghapus Simpul Tertentu (Simpul Depan)
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
cari
cari head
30
Menghapus Simpul Tertentu (Simpul Depan)
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
cari
cari head if(cari-gtnamanama1) headhead-gtnex
t
31
Menghapus Simpul Tertentu (Simpul Depan)
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
NULL
cari
cari head if(cari-gtnamanama) headhead-gtnext
head-gtbeforeNULL
32
Menghapus Simpul Tertentu (Simpul Depan)
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
NULL
cari
cari head if(cari-gtnamanama) headhead-gtnext
head-gtbeforeNULL free(cari)
33
Menghapus Simpul Tertentu (Simpul Depan)
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
before
before
before
next
next
next
NULL
NULL
cari head if(cari-gtnamanama) headhead-gtnext
head-gtbeforeNULL free(cari)
34
Menghapus Simpul Tertentu (Simpul Akhir)
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
cari
caritail
35
Menghapus Simpul Tertentu (Simpul Akhir)
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
cari
tailtail-gtbefore
36
Menghapus Simpul Tertentu (Simpul Akhir)
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
cari
tailtail-gtbefore tail-gtnextNULL
37
Menghapus Simpul Tertentu (Simpul Akhir)
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
cari
tailtail-gtbefore tail-gtnextNULL free(cari)
38
Menghapus Simpul Tertentu (Simpul Akhir)
head
tail
nama3 nrp3
nama2 nrp2
nama1 nrp1
before
before
before
next
next
next
NULL
NULL

39
Menghapus Simpul Tertentu (Di Tengah)
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
cari
carihead
40
Menghapus Simpul Tertentu (Di Tengah)
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
cari
while (cari-gtnama!nama3) cari cari -gt next
41
Menghapus Simpul Tertentu (Di Tengah)
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
cari
while (cari-gtnama!nama3) cari cari -gt next
42
Menghapus Simpul Tertentu (Di Tengah)
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
cari
while (cari-gtnama!nama3) cari cari -gt next
43
Menghapus Simpul Tertentu (Di Tengah)
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
cari
cari-gtbefore-gtnextcari-gtnext
44
Menghapus Simpul Tertentu (Di Tengah)
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
cari
cari-gtnext-gtbeforecari-gtbefore
45
Menghapus Simpul Tertentu (Di Tengah)
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
cari
free(cari)
46
Menghapus Simpul Tertentu (Di Tengah)
head
tail
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
next
next
next
NULL
NULL

47
atau
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
stl
sbl
cari
while (cari-gtnama!nama3) cari cari -gt
next sblcari-gtbefore stlcari-gtnext
48
Menghapus Simpul Tertentu
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
sbl
stl
cari
sbl-gtnextstl
49
Menghapus Simpul Tertentu
head
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
stl
sbl
cari
sbl-gtnextstl stl-gtbeforesbl
50
Menghapus Simpul Tertentu
head
tail
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
next
next
next
NULL
NULL
cari-gtbefore-gtnext cari-gtnext cari-gtnext-gtbefor
e cari-gtbefore free(cari)
51
Menyisipkan sebagai simpul pertama
tail
head
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
sisip
namax nrpx
before
next
52
Menyisipkan sebagai simpul pertama
tail
head
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
sisip
namax nrpx
sisip-gtbeforeNULL
before
next
NULL
53
Menyisipkan sebagai simpul pertama
tail
head
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
NULL
sisip
namax nrpx
sisip-gtnexthead
before
next
NULL
54
Menyisipkan sebagai simpul pertama
tail
head
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
sisip
namax nrpx
head-gtbeforesisip
before
next
NULL
55
Menyisipkan sebagai simpul pertama
tail
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
next
next
next
next
NULL
sisip
head
namax nrpx
headsisip
before
next
NULL
56
Menyisipkan stl. simpul tertentu
tail
head
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
NULL
next
next
next
next
NULL
sisip
namax nrpx
before
next
57
Menyisipkan stl. simpul tertentu
tail
head
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
NULL
next
next
next
next
NULL
stl
sisip
stlhead while(stl-gtnama!nama3) stlstl-gtnext
namax nrpx
before
next
58
Menyisipkan stl. simpul tertentu
tail
head
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
NULL
next
next
next
next
NULL
stl
sisip
sisip-gtbeforestl
namax nrpx
before
next
59
Menyisipkan stl. simpul tertentu
tail
head
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
NULL
next
next
next
next
NULL
stl
sisip
sisip-gtbeforestl sisip-gtnextstl-gtnext
namax nrpx
before
next
60
Menyisipkan stl. simpul tertentu
tail
head
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
NULL
next
next
next
next
NULL
stl
sisip
sisip-gtbeforestl sisip-gtnextstl-gtnext stl-gtnex
t-gtbeforesisip
namax nrpx
before
next
61
Menyisipkan stl. simpul tertentu
tail
head
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
NULL
next
next
next
next
NULL
stl
sisip
sisip-gtbeforestl sisip-gtnextstl-gtnext stl-gtnex
t-gtbeforesisip stl-gtnextsisip
namax nrpx
before
next
62
Menyisipkan sbl. simpul tertentu
tail
head
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
NULL
next
next
next
next
NULL
sisip
namax nrpx
before
next
63
Menyisipkan sbl. simpul tertentu
tail
head
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
NULL
next
next
next
next
NULL
sbl
sisip
sblhead while(sbl-gtnama!nama3) sblsbl-gtnext
namax nrpx
before
next
64
Menyisipkan sbl. simpul tertentu
tail
head
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
NULL
next
next
next
next
NULL
sbl
sisip
sisip-gtnextsbl
namax nrpx
before
next
65
Menyisipkan sbl. simpul tertentu
tail
head
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
NULL
next
next
next
next
NULL
sbl
sisip
sisip-gtnextsbl sisip-gtbeforesbl-gtbefore
namax nrpx
before
next
66
Menyisipkan sbl. simpul tertentu
tail
head
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
NULL
next
next
next
next
NULL
sbl
sisip
sisip-gtnextsbl sisip-gtbeforesbl-gtbefore sbl-gtb
efore-gtnextsisip
namax nrpx
before
next
67
Menyisipkan sbl. simpul tertentu
tail
head
nama3 nrp3
nama2 nrp2
nama4 nrp4
nama1 nrp1
before
before
before
before
NULL
next
next
next
next
NULL
sbl
sisip
sisip-gtnextsbl sisip-gtbeforesbl-gtbefore sbl-gtb
efore-gtnextsisip sbl-gtbeforesisip
namax nrpx
before
next
About PowerShow.com