Beruflich Dokumente
Kultur Dokumente
Objectives
In this session, you will learn to:
Identify the features of linked lists
Implement a singly-linked list
Ver. 1.0
Session 7
Ver. 1.0
Session 7
Ver. 1.0
Session 7
Ver. 1.0
Session 7
Ver. 1.0
Session 7
0
1
2
3
4
5
6
7
8
9
1000
1002
1004
1006
1008
1010
1012
1014
1016
1018
Memory representation
Ver. 1.0
Session 7
0
1
2
3
4
5
6
7
8
9
1000
1002
1004
1006
1008
1010
1012
1014
1016
1018
Memory representation
Ver. 1.0
Session 7
1002
Memory representation
Ver. 1.0
Session 7
1002
1036
Memory representation
Ver. 1.0
Session 7
1002
1008
1036
Memory representation
Ver. 1.0
Session 7
1002
1008
1020
1036
Memory representation
Ver. 1.0
Session 7
1002
1008
1020
1030
11
1036
Memory representation
Ver. 1.0
Session 7
1008
1020
1030
11
1036
Memory representation
Ver. 1.0
Session 7
1036
1008
1020
1020
1030
1030
11
1036
1008
Memory representation
Ver. 1.0
Session 7
1002
1036
1008
1020
1020
1030
1030
11
1036
1008
Memory representation
Ver. 1.0
Session 7
Ver. 1.0
Session 7
Data
Link
Node
Ver. 1.0
Session 7
10 3352
Data
2403
Ver. 1.0
10 5689
Data
3352
10 1012
Data
5689
10
Data
1012
Session 7
START
10 3352
Data
2403
Ver. 1.0
10 5689
Data
3352
10 1012
Data
5689
10
Data
1012
Session 7
Ver. 1.0
Session 7
Ver. 1.0
Session 7
Ver. 1.0
1.
2.
3.
4.
5.
6.
Ver. 1.0
1.
2.
3.
4.
5.
6.
Ver. 1.0
1.
2.
3.
4.
5.
6.
1.
2.
3.
4.
5.
6.
210
Ver. 1.0
Session 7
1.
2.
3.
4.
5.
6.
210
Ver. 1.0
Session 7
START
1.
2.
3.
4.
5.
6.
210
Ver. 1.0
Session 7
START
1.
2.
3.
4.
5.
6.
210
Ver. 1.0
Session 7
START
1.
2.
3.
4.
5.
6.
210
Insertion complete
Ver. 1.0
Session 7
START
1.
2.
3.
4.
5.
6.
210
Ver. 1.0
Session 7
START
1.
2.
3.
4.
5.
6.
210
Ver. 1.0
Session 7
START
210
Ver. 1.0
1.
2.
3.
4.
5.
6.
310
Session 7
START
210
Ver. 1.0
1.
2.
3.
4.
5.
6.
310
Session 7
START
210
Ver. 1.0
1.
2.
3.
4.
5.
6.
310
Session 7
START
210
1.
2.
3.
4.
5.
6.
310
currentNode
Ver. 1.0
Session 7
START
210
1.
2.
3.
4.
5.
6.
310
currentNode
Ver. 1.0
Session 7
START
210
1.
2.
3.
4.
5.
6.
310
currentNode
Ver. 1.0
Session 7
START
210
1.
2.
3.
4.
5.
6.
310
currentNode
Insertion complete
Ver. 1.0
Session 7
START
210
1.
2.
3.
4.
5.
6.
310
currentNode
Ver. 1.0
Session 7
START
210
Ver. 1.0
1.
2.
3.
4.
5.
6.
310
Session 7
START
210
Ver. 1.0
310
1.
2.
3.
4.
5.
6.
5
10
Session 7
START
210
Ver. 1.0
310
1.
2.
3.
4.
5.
6.
5
10
Session 7
START
210
Ver. 1.0
310
1.
2.
3.
4.
5.
6.
5
10
Session 7
START
210
310
1.
2.
3.
4.
5.
6.
5
10
currentNode
Ver. 1.0
Session 7
START
210
310
1.
2.
3.
4.
5.
6.
5
10
currentNode
Ver. 1.0
Session 7
START
210
310
1.
2.
3.
4.
5.
6.
5
10
currentNodecurrentNode
Ver. 1.0
Session 7
START
210
310
1.
2.
3.
4.
5.
6.
5
10
currentNode
Ver. 1.0
Session 7
START
210
310
1.
2.
3.
4.
5.
6.
5
10
currentNode
Insertion complete
Ver. 1.0
Session 7
1.
2.
3.
4.
5.
6.
Ver. 1.0
Session 7
Ver. 1.0
1.
2.
3.
4.
5.
6.
Session 7
Ver. 1.0
1.
2.
3.
4.
5.
6.
Session 7
Ver. 1.0
1.
2.
3.
4.
5.
6.
Session 7
2
10
Ver. 1.0
1.
2.
3.
4.
5.
6.
Session 7
2
10
Ver. 1.0
1.
2.
3.
4.
5.
6.
Session 7
1.
2.
3.
4.
5.
6.
START
2
10
Ver. 1.0
Session 7
LAST = NULL
1.
2.
3.
4.
5.
6.
START LAST
2
10
Ver. 1.0
Session 7
1.
2.
3.
4.
5.
6.
START LAST
2
10
Ver. 1.0
Session 7
1.
2.
3.
4.
5.
6.
START LAST
2
10
Insertion complete
Ver. 1.0
Session 7
1.
2.
3.
4.
5.
6.
START LAST
2
10
Ver. 1.0
Session 7
1.
2.
3.
4.
5.
6.
START LAST
2
10
Ver. 1.0
Session 7
1.
2.
3.
4.
5.
6.
START LAST
2
10
Ver. 1.0
3
10
Session 7
1.
2.
3.
4.
5.
6.
START LAST
2
10
Ver. 1.0
3
10
Session 7
1.
2.
3.
4.
5.
6.
START LAST
2
10
Ver. 1.0
3
10
Session 7
START LAST
2
10
Ver. 1.0
1.
2.
3.
4.
5.
6.
LAST
3
10
Session 7
START
2
10
2.
3.
4.
5.
6.
LAST
3
10
Insertion complete
Ver. 1.0
1.
Session 7
START
2
10
Ver. 1.0
1.
2.
3.
4.
5.
6.
LAST
3
10
Session 7
START
2
10
Ver. 1.0
1.
2.
3.
4.
5.
6.
LAST
3
10
Session 7
START
2
10
Ver. 1.0
1.
2.
3.
4.
5.
6.
LAST
3
10
5
10
Session 7
START
2
10
Ver. 1.0
1.
2.
3.
4.
5.
6.
LAST
3
10
5
10
Session 7
START
2
10
Ver. 1.0
1.
2.
3.
4.
5.
6.
LAST
3
10
5
10
Session 7
START
2
10
Ver. 1.0
LAST
3
10
1.
2.
3.
4.
5.
6.
LAST
5
10
Session 7
START
2
10
2.
3.
4.
5.
6.
LAST
3
10
Insertion complete
Ver. 1.0
1.
5
10
Session 7
Ver. 1.0
Session 7
Ver. 1.0
Session 7
Ver. 1.0
1.
2.
Set N = 0
Repeat until N = 20
a.
Accept marks.
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
19
Session 7
1.
2.
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
10
0
19
N=0
Ver. 1.0
Session 7
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
10
0
19
N=0
Ver. 1.0
Session 7
marks = 10
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
10
0
19
N=0
Ver. 1.0
Session 7
marks = 10
I=0
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
10
0
19
N=0
Ver. 1.0
Session 7
marks = 10
I=0
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
10
0
19
N=0
Ver. 1.0
Session 7
marks = 10
I=0
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
10
10
0
19
N=0
Ver. 1.0
Session 7
I=0
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
10
10
0
19
N=0
Ver. 1.0
Session 7
I=0
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
10
10
0
19
N=1
Ver. 1.0
Session 7
marks = 20
I=0
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
10
10
0
19
N=1
Ver. 1.0
Session 7
marks = 20
I=0
1
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
10
10
0
19
N=1
Ver. 1.0
Session 7
marks = 20
I=1
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
10
10
0
19
N=1
Ver. 1.0
Session 7
marks = 20
I=1
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
10 20
10
0
19
N=1
Ver. 1.0
Session 7
I=1
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
10 20
10
0
19
N=1
Ver. 1.0
Session 7
I=1
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
10 20
10
0
19
N=2
Ver. 1.0
Session 7
marks = 17
I=1
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
10 20
10
0
19
N=2
Ver. 1.0
Session 7
marks = 17
I=1
I
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
10 20
10
0
19
N=2
Ver. 1.0
Session 7
marks = 17
I=1
J=1
I
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
10 20
10
0
19
N=2
Ver. 1.0
Session 7
marks = 17
I=1
J=1
I
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
10 20
10
0
19
N=2
Ver. 1.0
Session 7
marks = 17
I=1
J=1
I
10 20
10
20
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
19
N=2
Ver. 1.0
Session 7
marks = 17
I=1
J=1
I
10 17
10
20
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
19
N=2
Ver. 1.0
Session 7
I=1
I
10 17
10
20
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
19
N=3
Ver. 1.0
Session 7
marks = 15
10 17
10
20
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
19
N=3
Ver. 1.0
Session 7
marks = 15
I=1
I
10 17
10
20
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
19
N=3
Ver. 1.0
Session 7
marks = 15
I=1
J=2
I
10 17
10
20
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
19
N=3
Ver. 1.0
Session 7
marks = 15
I=1
J=2
I
10 17
10
20
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
19
N=3
Ver. 1.0
Session 7
marks = 15
I=1
J=2
I
10 17
10
20
20
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
19
N=3
Ver. 1.0
Session 7
marks = 15
I=1
J=1
I
10 17
10
0
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
20
19
N=3
Ver. 1.0
Session 7
marks = 15
I=1
J=1
I
10 17
10
0
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
20
19
N=3
Ver. 1.0
Session 7
marks = 15
I=1
J=1
I
10 17
10
17
20
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
19
N=3
Ver. 1.0
Session 7
marks = 15
I=1
J=1
I
10 15
10
17
20
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
19
N=3
Ver. 1.0
Session 7
I=1
J=1
I
10 15
10
17
20
Set N = 0
Repeat until N = 20
a.
Accept marks
b.
Locate position I where
the marks must be
inserted
c.
For J = N-1 down to I
Move A[J] to A[J+1]
d.
Set A[I] = marks
e.
N=N+1
19
N=4
Ver. 1.0
Session 7
Ver. 1.0
Session 7
START
10 2496
15 1002
20 1020
25 NULL
10
1011
25
1020
15
2496
Memory representation
Ver. 1.0
Session 7
10
20
1002
10
1011
17
1008
25
1020
15
2496
17
15 1002
10
20 1020
10
25 NULL
10
Memory representation
Ver. 1.0
Session 7
10
20
1002
10
1011
17
1008
25
1020
15
2496
17
15 1002
10
20 1020
10
25 NULL
10
Memory representation
Ver. 1.0
Session 7
10
1002
10
1011
17
1008
25
1020
15
2496
17
START
10 2496
20
15 1002
10
17
20 1020
10
25 NULL
10
Memory representation
Ver. 1.0
Session 7
START
10 2496
10
1008
15 1002
10
17
Ver. 1.0
20 1020
10
25 NULL
10
20
1002
10
1011
17
1008
25
1020
15
2496
Memory representation
Session 7
Node Inserted
START
10 2496
10
15 1008
17 1002
20 1020
10
25 NULL
10
20
1002
10
1011
17
1008
25
1020
15
2496
Address updated
Memory representation
Ver. 1.0
Session 7
15
17
20
Ver. 1.0
Session 7
Ver. 1.0
Session 7
Ver. 1.0
1.
2.
3.
4.
5.
Session 7
START
10
Ver. 1.0
15
17
1.
2.
3.
4.
5.
20
Session 7
START
10
10
15
17
1.
2.
3.
4.
5.
20
current
Ver. 1.0
Session 7
START
10
10
15
17
1.
2.
3.
4.
5.
20
current
previous = NULL
Ver. 1.0
Session 7
START
10
10
15
17
1.
2.
3.
4.
5.
20
current
previous = NULL
Ver. 1.0
Session 7
START
10
10
15
17
1.
2.
3.
4.
5.
20
previous current
previous = NULL
Ver. 1.0
Session 7
START
10
10
previous current
Ver. 1.0
15
17
1.
2.
3.
4.
5.
20
current
Session 7
START
10
10
previous
Ver. 1.0
15
17
1.
2.
3.
4.
5.
20
current
Session 7
START
10
10
15
17
1.
2.
3.
4.
5.
20
Ver. 1.0
Session 7
START
10
10
15
17
1.
2.
3.
4.
5.
20
Ver. 1.0
Session 7
START
10
10
15
previous
17
1.
2.
3.
4.
5.
20
current
Node located
Ver. 1.0
Session 7
Ver. 1.0
Session 7
Ver. 1.0
Session 7
START
10
Ver. 1.0
15
17
1.
2.
3.
4.
20
Session 7
START
10
10
Ver. 1.0
15
17
1.
2.
3.
4.
20
Session 7
START
10
10
Ver. 1.0
15
17
1.
2.
3.
4.
20
Session 7
newnode
7
START
10
10
15
17
1.
2.
3.
4.
20
Ver. 1.0
Session 7
newnode
7
START
10
10
15
17
1.
2.
3.
4.
20
Insertion complete
Ver. 1.0
Session 7
Ver. 1.0
Session 7
1.
2.
3.
4.
5.
Insert
Algorithm
16
to insert a node between
two nodes in a linked list.
START
10
Ver. 1.0
15
17
20
Session 7
1.
2.
3.
4.
5.
Insert 16
START
10
10
Ver. 1.0
15
17
20
Session 7
1.
2.
3.
4.
5.
Insert 16
START
10
10
15
17
20
current
Ver. 1.0
Session 7
1.
2.
3.
4.
5.
Insert 16
START
10
10
15
17
20
current
previous = NULL
Ver. 1.0
Session 7
1.
2.
3.
4.
5.
Insert 16
START
10
10
15
17
20
current
previous = NULL
Ver. 1.0
Session 7
1.
2.
3.
4.
5.
Insert 16
START
10
10
15
17
20
previous current
previous = NULL
Ver. 1.0
Session 7
1.
2.
3.
4.
5.
Insert 16
START
10
10
previous current
Ver. 1.0
15
17
20
current
Session 7
1.
2.
3.
4.
5.
Insert 16
START
10
10
previous
Ver. 1.0
15
17
20
current
Session 7
1.
2.
3.
4.
5.
Insert 16
START
10
10
15
17
20
Ver. 1.0
Session 7
1.
2.
3.
4.
5.
Insert 16
START
10
10
15
17
20
previous currentcurrent
Ver. 1.0
Session 7
1.
2.
3.
4.
5.
Insert 16
START
10
10
15
previous
17
current
Nodes located
Ver. 1.0
20
Session 7
1.
2.
3.
4.
5.
START
10
10
15
previous
17
current
Nodes located
Ver. 1.0
20
Session 7
15
previous
Ver. 1.0
2.
3.
4.
5.
16
START
10
10
1.
17
20
current
Session 7
15
previous
17
2.
3.
4.
5.
20
current
newnode.next = current
Ver. 1.0
16
START
10
10
1.
Session 7
2.
3.
4.
5.
16
START
10
10
1.
15
previous
17
20
current
newnode.next = current
previous.next = newnode
Insertion complete
Ver. 1.0
Session 7
Write an algorithm
to traverse
a singly-linked
list.
Algorithm
for traversing
a linked
list.
START
Ver. 1.0
2.
3.
4.
Session 7
START
2
10
3
10
5
10
7
10
1.
2.
3.
4.
currentNode
Ver. 1.0
Session 7
START
2
10
3
10
5
10
7
10
1.
2.
3.
4.
currentNode
Ver. 1.0
Session 7
START
2
10
3
10
5
10
7
10
1.
2.
3.
4.
currentNode
Ver. 1.0
Session 7
START
2
10
3
10
5
10
7
10
1.
2.
3.
4.
currentNode currentNode
Ver. 1.0
Session 7
START
2
10
3
10
5
10
7
10
1.
2.
3.
4.
currentNode
Ver. 1.0
Session 7
START
2
10
3
10
5
10
7
10
1.
2.
3.
4.
currentNode
Ver. 1.0
Session 7
START
2
10
3
10
5
10
7
10
1.
2.
3.
4.
currentNode currentNode
Ver. 1.0
Session 7
START
2
10
3
10
5
10
7
10
1.
2.
3.
4.
currentNode
Ver. 1.0
Session 7
START
2
10
3
10
5
10
7
10
1.
2.
3.
4.
currentNode
Ver. 1.0
Session 7
START
2
10
3
10
5
10
7
10
1.
2.
3.
4.
currentNode
currentNode
Ver. 1.0
Session 7
START
2
10
3
10
5
10
7
10
1.
2.
3.
4.
currentNode
Ver. 1.0
Session 7
START
2
10
3
10
5
10
7
10
1.
2.
3.
4.
currentNode
Ver. 1.0
Session 7
START
2
10
3
10
5
10
7
10
currentNode
Ver. 1.0
1.
2.
3.
4.
currentNode = NULL
Session 7
START
2
10
3
10
5
10
7
10
1.
2.
3.
4.
currentNode = NULL
Traversal complete
Ver. 1.0
Session 7
Ver. 1.0
Session 7
Ver. 1.0
Session 7
Ver. 1.0
15
17
1.
2.
3.
20
Session 7
START
10
10
15
17
1.
2.
3.
20
current
current = START
Ver. 1.0
Session 7
START
START
10
10
15
17
1.
2.
3.
20
current
current = START
START = START. next
Ver. 1.0
Session 7
START
10
15
17
1.
2.
3.
20
current
Memory released
current = START
START = START. next
Session 7
Ver. 1.0
Session 7
Ver. 1.0
15
17
20
2.
3.
Session 7
Delete 17
START
10
10
Ver. 1.0
15
17
20
2.
3.
Session 7
Delete 17
START
10
10
previous
Ver. 1.0
15
17
20
2.
3.
Session 7
Delete 17
START
10
10
previous current
Ver. 1.0
15
17
20
2.
3.
Session 7
Delete 17
START
10
10
previous current
Ver. 1.0
15
17
20
2.
3.
Session 7
Delete 17
START
10
10
previous current
Ver. 1.0
15
17
20
2.
3.
Session 7
Delete 17
START
10
10
previous current
Ver. 1.0
15
current
17
20
2.
3.
Session 7
Delete 17
START
10
10
previous
Ver. 1.0
15
current
17
20
2.
3.
Session 7
Delete 17
START
10
10
previous
Ver. 1.0
15
previous current
17
20
2.
3.
Session 7
Delete 17
START
10
10
15
17
Ver. 1.0
20
2.
3.
Session 7
Delete 17
START
10
10
15
previous
Ver. 1.0
17
current
20
2.
3.
Session 7
Delete 17
START
10
10
15
previous
17
current
20
2.
3.
previous.next = current.next
Ver. 1.0
Session 7
Delete 17
Delete operation complete
START
10
10
15
previous
17
current
20
2.
3.
previous.next = current.next
Ver. 1.0
Session 7
Ver. 1.0
Session 7
Ver. 1.0
Session 7
Answer:
sequential
Ver. 1.0
Session 7
//sequence
}
Ver. 1.0
Session 7
//CodeinC++
classNode
{
public:
intdata;
Node*next;
//Pointertothe
//nextnodein
//sequence
};
Ver. 1.0
Session 7
//theaddress
ofthe
//nextnodein
//sequence
}
Ver. 1.0
Session 7
Ver. 1.0
classList
{
privateNodeSTART;
List()
{
START=NULL;
}
publicvoidaddNode(intelement){}
publicboolsearch(intelement,refNodeprevious,
refNodecurrent){}
publicbooldelNode(intelement){}
publicvoidtraverse(){}
}
Session 7
Ver. 1.0
classList
{
Node*START;
public:
List()
{
START=NULL;
}
voidaddNode(intelement);
boolsearch(intelement,Node*previous,Node
*current);
booldelNode(intelement);
voidtraverse();
};
Session 7
Ver. 1.0
Session 7
Ver. 1.0
Session 7