Professional Documents
Culture Documents
DS10
DS10
A B C
Head
A linked list is a series of connected nodes
Each node contains at least
A piece of data (any type)
Pointer to the next node in the list
Head: pointer to the first node node
The last node points to NULL A
data pointer
Representation of LL in
Memory
Let LIST be a linked list. It will be maintained
in memory.
It requires two linear arrays INFO[K] & LINK[K]
It requires a variable name START &
It requires a nextpointer sentinel NULL
Example
INFO LINK
1 start from 9 to Null = 0
9
2
3 O 6
4 T 0
5
6 11
7 X 10
8
9 N 3
10 I 4
11 E 7
12
Traversing a LL
Traversing algo uses a pointer variable PTR which
points to the node i.e. currently being processed.
LINK[PTR] points to the next node to be processed.
PTR := LINK [PTR]
A B C
Algorithm
TRAVERSE(LIST, PTR, PROCESS)
1.Set PTR := START. [Initializes pointer PTR.]
2. Repeat Steps 3 & 4 while PTR != NULL.
3. Apply PROCESS to INFO[PTR].
4. Set PTR := LINK[PTR].
[PTR now points to the next node.]
[End of Step 2 loop.]
5. Exit.
Thank You!!!