Академический Документы
Профессиональный Документы
Культура Документы
Lecture 2
Linked Lists
Linked list
adjacency between any two elements are
maintained by means of links or pointers
dynamic data structures
29.07.09
IT 60101: Lecture #2
Linked List
A linked list is an ordered collection of finite,
homogeneous data elements called nodes where
the linear order is maintained by means of links or
pointers
LINK
DA TA
IT 60101: Lecture #2
H EAD ER
H eader
59
38
64
N 1
N 2
N 3
80
N 6
14
72
N 4
N5
D ATA
L IN K
41
42
43
44
45
46
47
48
49
38
14
59
80
72
50
45
50
.
.
.
64
.
.
.
43
.
.
.
M e m o ry
L o c a tio n
29.07.09
IT 60101: Lecture #2
47
41
A rra y o f
p o in te r s
N E W
X Y
H E A D E R
X Y
29.07.09
IT 60101: Lecture #2
HEADER
29.07.09
IT 60101: Lecture #2
IT 60101: Lecture #2
29.07.09
IT 60101: Lecture #2
F ro m
m e m o ry
bank
H EAD ER
2
X
29.07.09
X
1
IT 60101: Lecture #2
H EAD ER
X
1
p tr
29.07.09
IT 60101: Lecture #2
10
H EAD ER
X
p tr
KEY
29.07.09
IT 60101: Lecture #2
11
29.07.09
IT 60101: Lecture #2
12
p tr1
p tr
KEY
29.07.09
IT 60101: Lecture #2
13
p tr1
p tr
29.07.09
IT 60101: Lecture #2
14
p tr1
p tr
1
X
KEY
R e tu rn to th e m e m o ry b a n k
29.07.09
IT 60101: Lecture #2
15
L1
. . .
H EAD ER 2
T o m e m o ry b a n k
L2
X
. . .
29.07.09
IT 60101: Lecture #2
16
HEADER
29.07.09
IT 60101: Lecture #2
17
. . .
HEADER1
1
p tr1
p tr2
p tr2
2
HEADER2
. . .
R e tu rn to m e m o ry
29.07.09
IT 60101: Lecture #2
18
R L IN K
D ATA
. . .
29.07.09
IT 60101: Lecture #2
19
HEADER
p tr
. . .
a ) I n s e r t io n a t t h e f r o n t
p tr
HEADER
. . .
b ) In s e r tio n a t th e e n d
NEW
p tr
29.07.09
NEW
IT 60101: Lecture #2
c ) I n s e r t io n a t a n y in t e r m e d ia t e p o s it io n
20
p tr
p tr1
. . .
R e tu rn to th e m e m o ry b a n k
a ) D e le t io n a t t h e f r o n t
HEADER
p tr
p tr1
. . .
b ) D e le t io n a t t h e e n d
HEAD ER
p tr
p tr1
p tr2
KEY
R e tu rn to th e m e m o ry b a n k
29.07.09
IT
c ) D 60101:
e l e t i o n a t aLecture
n i n t e r m e d i #2
a t e p o s it io n
21
29.07.09
IT 60101: Lecture #2
22
R O W L IN K
DATA
C O L L IN K
29.07.09
IT 60101: Lecture #2
23
R ow
29.07.09
IT 60101: Lecture #2
24
RH1
RH2
RH3
R H4
RH5
RH6
CH1
1
C H2
2
CH3
CH4
CH5
3
A
5
M
1
P
3
L
1
K
P o in ts t o H E A D E R
29.07.09
5
O
6
C
IT 60101: Lecture #2
5
B
25
COEFF EXPO
-7
14
LINK
10
-5
29.07.09
IT 60101: Lecture #2
26
29.07.09
IT 60101: Lecture #2
27
29.07.09
IT 60101: Lecture #2
28