Introduction to Linked List
Introduction to Linked List
- Is a dynamic data structure.
- Allows memory to be allocated as and when it is required.
- Consists of a chain of elements, in which each element is referred to as a node.
- A node is the basic building block of a linked list.
- A node consists of two parts:
- Data: Refers to the information held by the node.
- Link: Holds the address of the next node in the list.
- All the nodes in a linked list are present at arbitrary memory locations.
- Therefore, every node in a linked list has a link field that stores the address of the next node in sequence.
- The last node in a linked list does not point to any other node. Therefore, it points to NULL.
- To keep track of the first node, declare a variable/pointer, START, which always points to the first node.
- When the list is empty, START contains, NULL.