Join Community Community

Data Structures and Algorithms

Linked List

Stack

If You Find Any Mistakes On Our Content or Want To make some Changes Then Report Now

Types of Linked List

There are several types of linked lists that are commonly used in data structure:

Singly linked list

A singly linked list is a type of linked list where each node contains a reference to the next node in the list, but not to the previous node. This means that it is only possible to traverse the list in one direction, from the head to the tail. Here is an example of a singly linked list in C:

struct node {
   int value;
   struct node *next;
};

struct node *head;

Doubly linked list

A doubly linked list is a type of linked list where each node contains references to both the next and previous nodes in the list. This allows for efficient traversal of the list in both directions. Here is an example of a doubly linked list in C:

struct node {
   int value;
   struct node *next;
   struct node *prev;
};

struct node *head;

Circular linked list

A circular linked list is a type of linked list where the last node in the list points back to the first node, forming a circular structure. This allows for efficient traversal of the list in either direction, as there is no end to the list. Here is an example of a circular linked list in C:

struct node {
   int value;
   struct node *next;
};

struct node *head;
head->next = head;  // last node points back to first node

Doubly Circular Linked list

A doubly circular linked list is a type of linked list that combines the features of a doubly linked list and a circular linked list. In a doubly circular linked list, each node contains references to both the next and previous nodes in the list, and the last node in the list points back to the first node, forming a circular structure. This allows for efficient traversal of the list in either direction, as there is no end to the list and it is possible to move backwards and forwards through the list.

Here is an example of a doubly circular linked list in C:

struct node {
   int value;
   struct node *next;
   struct node *prev;
};

struct node *head;
head->next = head;  // last node points back to first node
head->prev = head;  // first node points back to last node

Doubly circular linked lists are useful in situations where it is necessary to efficiently traverse a list in either direction and where it is desirable to have a circular structure that allows for easy insertion and deletion of elements at the beginning and end of the list.

Modefied By

Comments

#

Bug bounty – According to the online encyclopedia Wikipedia, the United States and India are the top countries from which researchers submit their bugs. India... Read Now

#

Bug bounty – According to the online encyclopedia Wikipedia, the United States and India are the top countries from which researchers submit their bugs. India... Read Now

Contents

We just added New Courses Notes Pdf

Search Pdf

We just added New Subjects

Search Subjects