Professional Documents
Culture Documents
Follow Us On :
bit.ly/oabrosist
@brother.code
Procedure insertFirst (input/output L : list, input P : address)
Kamus
Algoritma
if (first(L) = NULL) then
first(L) ← P
else
next(P) ← first(L)
first(L) ← P
Follow Us On :
bit.ly/oabrosist
@brother.code
Procedure deleteFirst(input/output L : list, output P : address)
Kamus
Algoritma
if (first(L) ≠ NULL) then
P ← first(L)
first(L) ← next(P)
next(P) ← NULL
Follow Us On :
bit.ly/oabrosist
@brother.code
DOUBLE LINKED LIST
Follow Us On :
bit.ly/oabrosist
@brother.code
Procedure insertFirst (input/output L : list, input P : address)
Kamus
Algoritma
if (first(L) = NULL) then
first(L) ← P
last(L) ← P
else
next(P) ← first(L)
prev(first(L)) ← P
first(L) ← P
Follow Us On :
bit.ly/oabrosist
@brother.code
Procedure deleteFirst (input/ouput L : list, ouput P : address)
Kamus
Algoritma
If (first(L) ≠ NULL) then
P ← first(L)
if (P = last(L)) then
first(L) ← NULL
last(L) ← NULL
else
first(L) ← next(P)
next(P) ← NULL
prev(first(L)) ← NULL
Follow Us On :
bit.ly/oabrosist
@brother.code
CIRCULAR SINGLE LINKED LIST
Follow Us On :
bit.ly/oabrosist
@brother.code
Procedure insertFirst (input/output L : list, input P : address)
Kamus
Q : address
Algoritma
if (first(L) = NULL) then
first(L) ← P
next(P) ← P
else
Q ← first(L)
while (next(Q) ≠ first(L)) do
Q ← next(Q)
next(Q) ← P
next(P) ← first(L)
first(L) ← P
Follow Us On :
bit.ly/oabrosist
@brother.code
Procedure deleteFirst(input/output L : list, output P : address)
Kamus
Q : address
Algoritma
if (first(L) ≠ NULL) then
P ← first(L)
if (next(P) = first(L)) then
next(P) ← NULL
first(L) ← NULL
else
Q ← first(L)
while (next(Q) ≠ first(L)) do
Q ← next(Q)
first(L) ← next(P)
next(Q) ← next(P)
next(P) ← NULL
Follow Us On :
bit.ly/oabrosist
@brother.code
Procedure deleteAfter(input/output L : list, input prec : address, output P : address)
Kamus
Algoritma
if ((first(L) ≠ NULL) and (prec ≠ NULL)) then
if (next(prec) = first(L)) then
deleteFirst(L, P)
else
P ← next(prec)
next(prec) ← next(P)
next(P) ← NULL
Follow Us On :
bit.ly/oabrosist
@brother.code
CIRCULAR DOUBLE LINKED LIST
Follow Us On :
bit.ly/oabrosist
@brother.code
Procedure insertFirst (input/output L : list, input P : address)
Kamus
Algoritma
if (first(L) = NULL) then
first(L) ← P
last(L) ← P
next(P) ← P
prev(P) ← P
else
next(last(L)) ←P
prev(P) ←last(L)
next(P) ← first(L)
prev(first(L)) ← P
first(L) ← P
Follow Us On :
bit.ly/oabrosist
@brother.code
Procedure deleteFirst (input/ouput L : list, ouput P : address)
Kamus
Algoritma
If (first(L) ≠ NULL) then
P ← first(L)
if (P = last(L)) then
next(P) ← NULL
prev(P) ← NULL
first(L) ← NULL
last(L) ← NULL
else
first(L) ← next(P)
next(last(L)) ← first(L)
prev(first(L)) ← last(L)
next(P) ← NULL
prev(P) ← NULL
Follow Us On :
bit.ly/oabrosist
@brother.code
Procedure deleteAfter (input/output L : list, input prec : address, output P : address)
Kamus
Algoritma
if ((first(L) ≠ NULL) and (prec ≠ NULL)) then
if (prec ≠ Last(L)) then
if (next(prec) = last(L)) then
deleteLast(L, P)
else
P ← next(prec)
next(prec) ← next(P)
prev(next(P)) ← prec
next(P) ← NULL
prev(P) ← NULL
else
deleteFirst(L, P)
Follow Us On :
bit.ly/oabrosist
@brother.code