Chapter 06 LinkedLists
Chapter 06 LinkedLists
Linked Lists
(Chapter 6)
2
Outline
Introduction
Singly Linked Lists
Doubly Linked Lists
Applications
3
DATA
LINK
8
DATA
LLINK RLINK
Procedure INSERT_DL(X, Y)
LLINK(X) = Y;
RLINK(X) = RLINK(Y);
LLINK(RLINK(Y)) = X;
RLINK(Y) = X;
end INSERT_DL.
13
procedure DELETE_DL(P, X)
if (X = P) then ABANDON_DELETE;
else
{RLINK(LLINK(X)) = RLINK(X);
LLINK(RLINK(X)) = LLINK(X);
Call RETURN(X); }
end DELETE_DL.
14
Data objects:
A list of nodes each holding one (or more) data field(s) DATA and
a single link field LINK. LIST points to the start node of the list.
Operations:
Check if list LIST is empty
CHECK_LIST_EMPTY ( LIST) (Boolean function)
Insert ITEM into the list LIST as the first element
INSERT_FIRST (LIST, ITEM)
Insert ITEM into the list LIST as the last element
INSERT_LAST (LIST, ITEM)
Insert ITEM into the list LIST in order
INSERT_ORDER (LIST, ITEM)
15