Notion of linked list (no implementation)

A linked list is a common data structure made of a chain of nodes in which each node contains a value and a pointer to the next node in the chain.

The head pointer points to the first node, and the last element of the list points to null. When the list is empty, the head pointer points to null.

Linked lists can dynamically increase in size and it is easy to insert and delete from a linked list because unlike arrays, we only need to change the pointers of the previous element and the next element to insert or delete an element.

Linked lists are typically used to create file systems, adjacency lists, ​and hash tables

Types of Linked Lists

  • Singly Linked List (Uni-directional)
  • Doubly Linked List (Bi-directional)
  • Circular Linked List

Node example:-


struct node   
{  
    int data;   
    struct node *next;  
};  
struct node *head, *ptr;   
ptr = (struct node *)malloc(sizeof(struct node *));  

c language tutorial learn c language study c language