C Programming language

adplus-dvertising
C - Linear Linked List
Previous Home Next

NULL Pointer: The next field of the last element of the list contains NULL rather than a valid address, this indicates the end of the list.

External pointer is a pointer that points to the very first node in the linked list, it enables us to access the entire linked list.

An Empty list is a list that contains no nodes in the list, it is also called a null list. The value of external pointer will zero for an empty list. A list can be made an empty list by assigning a NULL value to the external pointer. i.e.

head = NULL;// Where head is an external pointer.
Representation of Linear Linked List

Suppose we want to create a linked list of integers, we can represent a linked in the memory with the following declarations:

#include <stdio.h>
struct node
{
int a;
struct node *next;
};
typedef struct node NODE;
NODE *head;

The above declaration creates a new data type whose each element is of type node_type and gives it a name NODE. And here head created acts as an external pointer to the list.

Previous Home Next