Code Skiller logoCB Logo
Logo LearnLearnLogo PracticePracticeLogo HireHireLogo IDEIDE

Types of linked list

User image

Published by

sanya sanya

Published at: 3rd Aug, 2023
2.685 mins read

Singly linked list: A singly linked list is a linear data structure that consists of a sequence of nodes, each containing a value and a pointer pointing to the next node in the sequence.

  • The first node in the list is called the head node, and the last node is called the tail node. The tail node has a reference to NULL, indicating the end of the list.
  • Since the pointer points to the next node, this means that you can only traverse the list in one direction, from the head to the tail node, only.
  • Singly linked lists are commonly used to implement other data structures, such as stacks, queues, and hash tables. They are also used in a variety of applications, such as text editors, compilers, and operating systems.

Doubly linked list: A doubly linked list is a linear data structure that is similar to a singly linked list, but each node has a value and two pointers: one to the next node and one to the previous node.

  • The first node in the list is called the head node and has a null reference to the previous node. The last node in the list is called the tail node and has a null reference to the next node.
  • Doubly linked lists provide bidirectional traversal, meaning that you can traverse the list in both forward and backward directions.

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 loop, and each node has a single pointer that points to the next node in the list.

  • The last node in the list points to the first node in the list creating a loop. This means that the list can be traversed from any node in the list, not just from the head node. -Circular linked lists can be useful in situations where data needs to be accessed in a cyclical or circular manner.

Doubly circular linked list: A doubly circular linked list is a type of linked list where each node has a value and two pointers: to the next node and to the previous node.

  • In this, the previous pointer of the first node points to the last node. While the next pointer of the last node points to the first node of the list forming a loop. Hence, the list can be traversed in both forward and backward directions.

Header linked list: A header linked list includes an additional special node called a header node, which is the first node in the list and does not contain any actual data. Instead, it contains the reference to first actual data node in the list.

  • The header node can also contain other information, such as the length of the list, the type of data stored in the list, or any other metadata that is useful for the implementation of the list.
  • The purpose of the header node is to simplify the implementation of the linked list and to avoid certain edge cases that can occur with an empty or partially empty linked list.

Library

WEB DEVELOPMENT

FAANG QUESTIONS