|
Each record in the list is called a node.
Each node has a field which is a pointer to the next node in the linked list (ie its
address). The last node has a null pointer.
There is a Start Pointer which links to the first node of the list.
There may also be a Next Free Pointer giving the address of the next free record space.
Graphical representation of a Linked List :
Example:
The linked list shown has been assigned
pointers after a sorting process -
| Address |
Town |
Pointer |
| 1 |
Bridgend |
4 |
| 2 |
Swansea |
5 |
| 3 |
Reading |
2 |
| 4 |
Cardiff |
3 |
| 5 |
Swindon |
0 |
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| Start Pointer = 1 |
| Next Free Pointer
= 6 |
By following the links, the records can be
accessed in alphabetical order.
A better system is to use two linked lists - one to link all the free spaces
together -
| Address |
Town |
Pointer |
| 1 |
Bridgend |
4 |
| 2 |
Swansea |
5 |
| 3 |
Reading |
2 |
| 4 |
Cardiff |
3 |
| 5 |
Swindon |
0 |
| 6 |
|
7 |
| 7 |
|
8 |
| 8 |
|
0 |
| Start Pointer = 1 |
| Next Free Pointer
= 6 |
|