Linked List pada C++


Nih buat kamu yang lagi cari cara atau listing program insert awal, insert tengah, insert akhir, delete awal, delete tengah dan delete akhir Pada LINKED LIST :

a. Insert Awal
Baru = new struct simpul;
Baru Data = ‘B’;
Baru Link = NULL;
If (P!=NULL)
{
Baru Link = P;
P = Baru;
}

b. Insert Tengah
x = new simpul;
x = P;
while (x Link data !=’C’)
x = x Link;

Baru Link = x Link;
x Link = Baru;
c. Insert Belakang
Baru = new struct simpul;
Baru Data = ‘D’;
Baru Link = NULL;
x = new struct simpul;
x = P;
while (x Link != NULL)
x = x Link;
x Link = Baru;

d. Delete Awal
x = new simpul;
x = P;
P = P Link;
delete x;

e. Delete Tengah
y = new simpul;
y = P;
while (y Link data !=’E’)
y = y Link;
x = new simpul;
x = y Link;
y Link = x Link;
delete x;

f. Delete Belakang
y = new simpul;
y = P;
while (y Link data !=’F’)
y = y Link;
x = new simpul;
x = y Link;
y Link = x Link;
delete x;

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s