BCA Data Structure Unit 1 Notes
BCA Data Structure Unit 1 Notes
Linked List
A linked list is a sequence of nodes that contain two fields: data (an integer value here as an
example) and a link to the next node. The last node is linked to a terminator used to signify
the end of the list.
The field of each node that contains the address of the next node is usually called the 'next
link' or 'next pointer'. The remaining fields are known as the 'data', 'information', 'value',
'cargo', or 'payload' fields.
The 'head' of a list is its first node. The 'tail' of a list may refer either to the rest of the list after
the head, or to the last node in the list.
The above list is comprised of 4 nodes having four data points- A, B, C, D. Each node has
two links one pointing forward and one pointing backwards.
a. Data: It constitutes the value of the data item inside the list.
b. Prev: It is a pointer pointing towards the previous node. For the first node, Prev points to
NULL.
c. Next: It links the current node to the next node in the linked list. The ‘Next’ of the last
node points towards NULL.
The header node does not represent an item in the linked list. This data part of this node is
generally used to hold any global information about the entire linked list. The next part of the
header node points to the first node in the list.
A header linked is a special kind of linked list which contains a special node at the beginning
of the list. This special node is known as header node and contain important information
regarding the linked list. This information may be total number of nodes in list, some
description for the user like creation and modification data about, whether the data in the list
is sorted and unsorted.