Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • DSA
  • Interview Problems on Linked List
  • Practice Linked List
  • MCQs on Linked List
  • Linked List Tutorial
  • Types of Linked List
  • Singly Linked List
  • Doubly Linked List
  • Circular Linked List
  • Circular Doubly Linked List
  • Linked List vs Array
  • Time & Space Complexity
  • Advantages & Disadvantages
Open In App
Next Article:
Deletion from a Circular Linked List
Next article icon

Deletion from a Circular Linked List

Last Updated : 19 Dec, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report
Try it on GfG Practice
redirect icon

In this article, we will learn how to delete a node from a circular linked list. In a circular linked list, the last node connects back to the first node, creating a loop.

There are three main ways to delete a node from circular linked list:

  • Deletion at the beginning
  • Deletion at specific position
  • Deletion at the end

Now, let’s look at the methods and steps for these three deletion operations.

Deletion from a Circular Linked List:

Deletion involves removing a node from the linked list. The main difference is that we need to ensure the list remains circular after the deletion. We can delete a node in a circular linked list in three ways:

1. Deletion from the beginning of the circular linked list

To delete the first node of a circular linked list, we first check if the list is empty. If it is then we print a message and return NULL. If the list contains only one node (the head is the same as the last) then we delete that node and set the last pointer to NULL. If there are multiple nodes then we update the last->next pointer to skip the head node and effectively removing it from the list. We then delete the head node to free the allocated memory. Finally, we return the updated last pointer, which still points to the last node in the list.

Deletion-from-the-beginning-of-circular-linked-list
Delete the first node in circular linked list

Step-by-step approach:

  • Check if List is Empty:
    • If last is nullptr, print "List is empty" and return nullptr.
  • Get Head Node:
    • Set head to last->next.
  • Check for Single Node:
    • If head equals last, delete head and set last to nullptr.
  • Handle Multiple Nodes:
    • Update last->next to point to head->next.
    • Delete head.
  • Return Updated last

Below is the implementation of the above approach:

C++
#include <iostream> using namespace std;  struct Node {     int data;     Node* next;     Node(int value) {         data = value;         next = nullptr;     } };  // Function to delete the first node of the circular linked list Node* deleteFirstNode(Node* last) {     if (last == nullptr) {         // If the list is empty         cout << "List is empty" << endl;         return nullptr;     }      Node* head = last->next;      if (head == last) {         // If there is only one node in the list         delete head;         last = nullptr;     } else {         // More than one node in the list         last->next = head->next;         delete head;     }      return last; }  void printList(Node* last) {     if(last == NULL) return ;       Node *head = last->next;     while (true){         cout << head->data << " ";         head = head->next;         if (head == last->next) break;     }     cout << endl; }  int main() {     // Create circular linked list: 2, 3, 4     Node* first = new Node(2);     first->next = new Node(3);     first->next->next = new Node(4);      Node* last = first->next->next;     last->next = first;      cout << "Original list: ";     printList(last);      // Delete the first node     last = deleteFirstNode(last);      cout << "List after deleting first node: ";     printList(last);      return 0; } 
C
#include <stdio.h> #include <stdlib.h>  struct Node {     int data;     struct Node* next; };  struct Node* deleteFirstNode(struct Node* last) {     if (last == NULL) {         // If the list is empty         printf("List is empty\n");         return NULL;     }      struct Node* head = last->next;      if (head == last) {         // If there is only one node in the list         free(head);         last = NULL;     } else {         // More than one node in the list         last->next = head->next;         free(head);     }      return last; }  void printList(struct Node* last) {     if (last == NULL) return;      struct Node* head = last->next;     while (1) {         printf("%d ", head->data);         head = head->next;         if (head == last->next) break;     }     printf("\n"); }  struct Node* createNode(int value) {     struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));     newNode->data = value;     newNode->next = NULL;     return newNode; }  int main() {     struct Node* first = createNode(2);     first->next = createNode(3);     first->next->next = createNode(4);      struct Node* last = first->next->next;     last->next = first;      printf("Original list: ");     printList(last);      last = deleteFirstNode(last);      printf("List after deleting first node: ");     printList(last);      return 0; } 
Java
class Node {     int data;     Node next;      Node(int value) {         data = value;         next = null;     } }  public class GFG {     public static Node deleteFirstNode(Node last) {         if (last == null) {             // If the list is empty             System.out.println("List is empty");             return null;         }          Node head = last.next;          if (head == last) {             // If there is only one node in the list             last = null;         } else {             // More than one node in the list             last.next = head.next;         }          return last;     }      public static void printList(Node last) {         if (last == null) return;          Node head = last.next;         while (true) {             System.out.print(head.data + " ");             head = head.next;             if (head == last.next) break;         }         System.out.println();     }      public static void main(String[] args) {         // Create circular linked list: 2, 3, 4         Node first = new Node(2);         first.next = new Node(3);         first.next.next = new Node(4);          Node last = first.next.next;         last.next = first;          System.out.print("Original list: ");         printList(last);          // Delete the first node         last = deleteFirstNode(last);          System.out.print("List after deleting first node: ");         printList(last);     } } 
Python
class Node:     def __init__(self, data):         self.data = data         self.next = None  def deleteFirstNode(last):     if last is None:         # If the list is empty         print("List is empty")         return None      head = last.next      if head == last:         # If there is only one node in the list         last = None     else:         # More than one node in the list         last.next = head.next      return last  def print_list(last):     if last is None:         return      head = last.next     while True:         print(head.data, end=" ")         head = head.next         if head == last.next:             break     print()  # Create circular linked list: 2, 3, 4 first = Node(2) first.next = Node(3) first.next.next = Node(4)  last = first.next.next last.next = first  print("Original list: ", end="") print_list(last)  # Delete the first node last = deleteFirstNode(last)  print("List after deleting first node: ", end="") print_list(last) 
JavaScript
class Node {     constructor(data) {         this.data = data;         this.next = null;     } }  function deleteFirstNode(last) {     if (last === null) {         // If the list is empty         console.log("List is empty");         return null;     }      let head = last.next;      if (head === last) {         // If there is only one node in the list         last = null;     } else {         // More than one node in the list         last.next = head.next;     }      return last; }  function printList(last) {     if (last === null) return;      let head = last.next;     while (true) {         console.log(head.data + " ");         head = head.next;         if (head === last.next) break;     }     console.log(); }  // Create circular linked list: 2, 3, 4 let first = new Node(2); first.next = new Node(3); first.next.next = new Node(4);  let last = first.next.next; last.next = first;  console.log("Original list: "); printList(last);  // Delete the first node last = deleteFirstNode(last);  console.log("List after deleting first node: "); printList(last); 

Output
Original list: 2 3 4  List after deleting first node: 3 4  

Time Complexity: O(1)
Auxiliary Space: O(1)

2. Deletion at specific position in circular linked list

To delete a specific node from a circular linked list, we first check if the list is empty. If it is then we print a message and return nullptr. If the list contains only one node and it matches the key then we delete that node and set last to nullptr. If the node to be deleted is the first node then we update the next pointer of the last node to skip the head node and delete the head. For other nodes, we traverse the list using two pointers: curr (to find the node) and prev (to keep track of the previous node). If we find the node with the matching key then we update the next pointer of prev to skip the curr node and delete it. If the node is found and it is the last node, we update the last pointer accordingly. If the node is not found then do nothing and tail or last as it is. Finally, we return the updated last pointer.

Delete-a-specific-node-in-circular-linked-list
Delete a specific node in circular linked list

Step-by-step approach:

  • Check if List is Empty (last is nullptr) then print "List is empty, nothing to delete" and return nullptr.
  • Set curr to last->next (head) and prev to last.
  • Check for single node, if node's data matches key, delete it and set last to nullptr.
  • Check for first node to delete, if head node's data matches key, update last->next and delete the head.
  • Loop through the list to find the node with the specified key.
    • If node found then update prev->next to skip the deleted node. If the deleted node is last, update last to prev.
    • Otherwise, print "Node with data [key] not found."
  • Return the modified last.

Below is the implementation of the above approach:

C++
#include <iostream> using namespace std;  struct Node {     int data;     Node* next;     Node(int value) {         data = value;         next = nullptr;     } };  // Function to delete a specific node in the circular linked list Node* deleteSpecificNode(Node* last, int key) {     if (last == nullptr) {         // If the list is empty         cout << "List is empty, nothing to delete." << endl;         return nullptr;     }      Node* curr = last->next;     Node* prev = last;      // If the node to be deleted is the only node in the list     if (curr == last && curr->data == key) {         delete curr;         last = nullptr;         return last;     }      // If the node to be deleted is the first node     if (curr->data == key) {         last->next = curr->next;         delete curr;         return last;     }      // Traverse the list to find the node to be deleted     while (curr != last && curr->data != key) {         prev = curr;         curr = curr->next;     }      // If the node to be deleted is found     if (curr->data == key) {         prev->next = curr->next;         if (curr == last) {             last = prev;         }         delete curr;     } else {         // If the node to be deleted is not found         cout << "Node with data " << key           << " not found." << endl;     }      return last; }  // Function to print the circular linked list void printList(Node* last) {      if (last == NULL){         cout << "List is Empty";         return;     }      Node *head = last->next;     while (true){         cout << head->data << " ";         head = head->next;         if (head == last->next) break;     }     cout << endl; }  int main() {     // Create circular linked list: 2, 3, 4     Node* first = new Node(2);     first->next = new Node(3);     first->next->next = new Node(4);      Node* last = first->next->next;     last->next = first;      cout << "Original list: ";     printList(last);      // Delete a specific node     int key = 3;     last = deleteSpecificNode(last, key);      cout << "List after deleting node " << key << ": ";     printList(last);      return 0; } 
C
#include <stdio.h> #include <stdlib.h>  // Define the structure for a node in the circular linked list struct Node {     int data;     struct Node* next; };  // Function to delete a specific node in the circular linked list struct Node* deleteSpecificNode(struct Node* last, int key) {     if (last == NULL) {         // If the list is empty         printf("List is empty, nothing to delete.\n");         return NULL;     }      struct Node* curr = last->next;     struct Node* prev = last;      // If the node to be deleted is the only node in the list     if (curr == last && curr->data == key) {         free(curr);         last = NULL;         return last;     }      // If the node to be deleted is the first node     if (curr->data == key) {         last->next = curr->next;         free(curr);         return last;     }      // Traverse the list to find the node to be deleted     while (curr != last && curr->data != key) {         prev = curr;         curr = curr->next;     }      // If the node to be deleted is found     if (curr->data == key) {         prev->next = curr->next;         if (curr == last) {             last = prev;         }         free(curr);     } else {         // If the node to be deleted is not found         printf("Node with data %d not found.\n", key);     }      return last; }  void printList(struct Node* last) {     if (last == NULL) {         printf("List is Empty");         return;     }      struct Node* head = last->next;     while (1) {         printf("%d ", head->data);         head = head->next;         if (head == last->next) break;     }     printf("\n"); }  struct Node* createNode(int value) {     struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));     newNode->data = value;     newNode->next = NULL;     return newNode; }  int main() {     // Create circular linked list: 2, 3, 4     struct Node* first = createNode(2);     first->next = createNode(3);     first->next->next = createNode(4);      struct Node* last = first->next->next;     last->next = first;      printf("Original list: ");     printList(last);      // Delete a specific node     int key = 3;     last = deleteSpecificNode(last, key);      printf("List after deleting node %d: ", key);     printList(last);      return 0; } 
Java
class Node {     int data;     Node next;     Node(int value){         data = value;         next = null;     } }  public class GFG {     public static Node deleteSpecificNode(Node last,                                           int key){         if (last == null) {             // If the list is empty             System.out.println(                 "List is empty, nothing to delete.");             return null;         }         Node curr = last.next;         Node prev = last;          // If the node to be deleted is the only node in the         // list         if (curr == last && curr.data == key) {             last = null;             return last;         }          // If the node to be deleted is the first node         if (curr.data == key) {             last.next = curr.next;             return last;         }          // Traverse the list to find the node to be deleted         while (curr != last && curr.data != key) {             prev = curr;             curr = curr.next;         }          // If the node to be deleted is found         if (curr.data == key) {             prev.next = curr.next;             if (curr == last) {                 last = prev;             }         }         else {             // If the node to be deleted is not found             System.out.println("Node with data " + key                                + " not found.");         }         return last;     }      public static void printList(Node last){         if (last == null) {             System.out.println("List is Empty");             return;         }                Node head = last.next;         while (true) {             System.out.print(head.data + " ");             head = head.next;             if (head == last.next)                 break;         }         System.out.println();     }      public static void main(String[] args){         // Create circular linked list: 2, 3, 4         Node first = new Node(2);         first.next = new Node(3);         first.next.next = new Node(4);          Node last = first.next.next;         last.next = first;          System.out.print("Original list: ");         printList(last);          // Delete a specific node         int key = 3;         last = deleteSpecificNode(last, key);          System.out.print("List after deleting node " + key                          + ": ");         printList(last);     } } 
Python
class Node:     def __init__(self, data):         self.data = data         self.next = None  def deleteSpecificNode(last, key):     if last is None:         # If the list is empty         print("List is empty, nothing to delete.")         return None      curr = last.next     prev = last      # If the node to be deleted is the only node in the list     if curr == last and curr.data == key:         last = None         return last      # If the node to be deleted is the first node     if curr.data == key:         last.next = curr.next         return last      # Traverse the list to find the node to be deleted     while curr != last and curr.data != key:         prev = curr         curr = curr.next      # If the node to be deleted is found     if curr.data == key:         prev.next = curr.next         if curr == last:             last = prev     else:         # If the node to be deleted is not found         print(f"Node with data {key} not found.")      return last  def printList(last):     if last is None:         print("List is Empty")         return      head = last.next     while True:         print(head.data, end=" ")         head = head.next         if head == last.next:             break     print()  # Create circular linked list: 2, 3, 4 first = Node(2) first.next = Node(3) first.next.next = Node(4)  last = first.next.next last.next = first  print("Original list: ", end="") printList(last)  # Delete a specific node key = 3 last = deleteSpecificNode(last, key)  print(f"List after deleting node {key}: ", end="") printList(last) 
JavaScript
class Node {     constructor(data) {         this.data = data;         this.next = null;     } }  function deleteSpecificNode(last, key) {     if (last === null) {         // If the list is empty         console.log("List is empty, nothing to delete.");         return null;     }      let curr = last.next;     let prev = last;      // If the node to be deleted is the only node in the list     if (curr === last && curr.data === key) {         last = null;         return last;     }      // If the node to be deleted is the first node     if (curr.data === key) {         last.next = curr.next;         return last;     }      // Traverse the list to find the node to be deleted     while (curr !== last && curr.data !== key) {         prev = curr;         curr = curr.next;     }      // If the node to be deleted is found     if (curr.data === key) {         prev.next = curr.next;         if (curr === last) {             last = prev;         }     } else {         // If the node to be deleted is not found         console.log("Node with data " + key + " not found.");     }      return last; }  function printList(last) {     if (last === null) {         console.log("List is Empty");         return;     }      let head = last.next;     while (true) {         console.log(head.data + " ");         head = head.next;         if (head === last.next) break;     }     console.log(); }  // Create circular linked list: 2, 3, 4 let first = new Node(2); first.next = new Node(3); first.next.next = new Node(4);  let last = first.next.next; last.next = first;  console.log("Original list: "); printList(last);  // Delete a specific node let key = 3; last = deleteSpecificNode(last, key);  console.log("List after deleting node " + key + ": "); printList(last); 

Output
Original list: 2 3 4  List after deleting node 3: 2 4  

Time Complexity: O(n), due to traversing the list to find the specific position
Auxiliary Space: O(1)

3. Deletion at the end of Circular linked list

To delete the last node in a circular linked list, we first check if the list is empty. If it is, we print a message and return nullptr. If the list contains only one node (where the head is the same as the last), we delete that node and set last to nullptr. For lists with multiple nodes, we need to traverse the list to find the second last node. We do this by starting from the head and moving through the list until we reach the node whose next pointer points to last. Once we find the second last node then we update its next pointer to point back to the head, this effectively removing the last node from the list. We then delete the last node to free up memory and return the updated last pointer, which now points to the last node.

Deletion-at-the-end-of-circular-linked-list
Deletion at the end of Circular linked list

Step-by-step approach:

  • Check if List is Empty (last is nullptr) then print "List is empty, nothing to delete" and return nullptr.
  • Get head node by Setting head to last->next.
  • Check for single node, if head equals last, delete last and set last to nullptr.
  • Find second last node by traversing the list until curr->next equals last.
  • Update Pointer by setting curr->next to point to head.
  • Delete last and update last to curr.
  • Return the updated last.

Below is the implementation of the above approach:

C++
#include <iostream> using namespace std;  struct Node {     int data;     Node* next;     Node(int value) {         data = value;         next = nullptr;     } };  // Function to delete the last node in the circular linked list Node* deleteLastNode(Node* last) {     if (last == nullptr) {         // If the list is empty         cout << "List is empty, nothing to delete." << endl;         return nullptr;     }     Node* head = last->next;      // If there is only one node in the list     if (head == last) {         delete last;         last = nullptr;         return last;     }     // Traverse the list to find the second last node     Node* curr = head;     while (curr->next != last) {         curr = curr->next;     }     // Update the second last node's next pointer     // to point to head     curr->next = head;     delete last;     last = curr;      return last; }  void printList(Node* last) {    if(last == NULL) return;      Node *head = last->next;     while (true){         cout << head->data << " ";         head = head->next;         if (head == last->next) break;     }     cout << endl; }  int main() {     // Create circular linked list: 2, 3, 4     Node* first = new Node(2);     first->next = new Node(3);     first->next->next = new Node(4);      Node* last = first->next->next;     last->next = first;      cout << "Original list: ";     printList(last);      // Delete the last node     last = deleteLastNode(last);      cout << "List after deleting last node: ";     printList(last);      return 0; } 
C
#include <stdio.h> #include <stdlib.h>  // Define the structure for a node in the circular linked list struct Node {     int data;     struct Node* next; };  // Function to delete the last node in the circular linked list struct Node* deleteLastNode(struct Node* last) {     if (last == NULL) {         // If the list is empty         printf("List is empty, nothing to delete.\n");         return NULL;     }     struct Node* head = last->next;      // If there is only one node in the list     if (head == last) {         free(last);         last = NULL;         return last;     }     // Traverse the list to find the second last node     struct Node* curr = head;     while (curr->next != last) {         curr = curr->next;     }     // Update the second last node's next pointer to point to head     curr->next = head;     free(last);     last = curr;      return last; }  void printList(struct Node* last) {     if (last == NULL) return;      struct Node* head = last->next;     while (1) {         printf("%d ", head->data);         head = head->next;         if (head == last->next) break;     }     printf("\n"); }  struct Node* createNode(int value) {     struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));     newNode->data = value;     newNode->next = NULL;     return newNode; }  int main() {     // Create circular linked list: 2, 3, 4     struct Node* first = createNode(2);     first->next = createNode(3);     first->next->next = createNode(4);      struct Node* last = first->next->next;     last->next = first;      printf("Original list: ");     printList(last);      // Delete the last node     last = deleteLastNode(last);      printf("List after deleting last node: ");     printList(last);      return 0; } 
Java
class Node {     int data;     Node next;      Node(int value){         data = value;         next = null;     } }  public class GFG {     public static Node deleteLastNode(Node last){         if (last == null) {             // If the list is empty             System.out.println(                 "List is empty, nothing to delete.");             return null;         }         Node head = last.next;          // If there is only one node in the list         if (head == last) {             last = null;             return last;         }         // Traverse the list to find the second last node         Node curr = head;         while (curr.next != last) {             curr = curr.next;         }         // Update the second last node's next pointer to         // point to head         curr.next = head;         last = curr;          return last;     }      public static void printList(Node last){         if (last == null)             return;          Node head = last.next;         while (true) {             System.out.print(head.data + " ");             head = head.next;             if (head == last.next)                 break;         }         System.out.println();     }      public static void main(String[] args){         // Create circular linked list: 2, 3, 4         Node first = new Node(2);         first.next = new Node(3);         first.next.next = new Node(4);          Node last = first.next.next;         last.next = first;          System.out.print("Original list: ");         printList(last);          // Delete the last node         last = deleteLastNode(last);          System.out.print("List after deleting last node: ");         printList(last);     } } 
Python
class Node:     def __init__(self, data):         self.data = data         self.next = None  def deleteLastNode(last):     if last is None:         # If the list is empty         print("List is empty, nothing to delete.")         return None      head = last.next      # If there is only one node in the list     if head == last:         last = None         return last      # Traverse the list to find the second last node     curr = head     while curr.next != last:         curr = curr.next      # Update the second last node's next pointer to point to head     curr.next = head     last = curr      return last  def printList(last):     if last is None:         return      head = last.next     while True:         print(head.data, end=" ")         head = head.next         if head == last.next:             break     print()  # Create circular linked list: 2, 3, 4 first = Node(2) first.next = Node(3) first.next.next = Node(4)  last = first.next.next last.next = first  print("Original list: ", end="") printList(last)  # Delete the last node last = deleteLastNode(last)  print("List after deleting last node: ", end="") printList(last) 
C#
using System;  public class Node {     public int data;     public Node next;      public Node(int value)     {         data = value;         next = null;     } }  public class GFG {     // Function to delete the last node in the circular     // linked list     public static Node deleteLastNode(Node last)     {         if (last == null) {             // If the list is empty             Console.WriteLine(                 "List is empty, nothing to delete.");             return null;         }         Node head = last.next;          // If there is only one node in the list         if (head == last) {             last = null;             return last;         }         // Traverse the list to find the second last node         Node curr = head;         while (curr.next != last) {             curr = curr.next;         }         // Update the second last node's next pointer         // to point to head         curr.next = head;         last = curr;          return last;     }      // Function to print the circular linked list     public static void printList(Node last)     {         if (last == null) {             Console.WriteLine("List is Empty");             return;         }          Node head = last.next;         while (true) {             Console.Write(head.data + " ");             head = head.next;             if (head == last.next)                 break;         }         Console.WriteLine();     }      public static void Main(string[] args)     {         // Create circular linked list: 2, 3, 4         Node first = new Node(2);         first.next = new Node(3);         first.next.next = new Node(4);          Node last = first.next.next;         last.next = first;          Console.Write("Original list: ");         printList(last);          // Delete the last node         last = deleteLastNode(last);          Console.Write("List after deleting last node: ");         printList(last);     } } 
JavaScript
class Node {     constructor(data) {         this.data = data;         this.next = null;     } }  function deleteLastNode(last) {     if (last === null) {         // If the list is empty         console.log("List is empty, nothing to delete.");         return null;     }     let head = last.next;      // If there is only one node in the list     if (head === last) {         last = null;         return last;     }     // Traverse the list to find the second last node     let curr = head;     while (curr.next !== last) {         curr = curr.next;     }     // Update the second last node's next pointer to point to head     curr.next = head;     last = curr;      return last; }  function printList(last) {     if (last === null) return;      let head = last.next;     while (true) {         process.stdout.write(head.data + " ");         head = head.next;         if (head === last.next) break;     }     console.log(); }  // Create circular linked list: 2, 3, 4 let first = new Node(2); first.next = new Node(3); first.next.next = new Node(4);  let last = first.next.next; last.next = first;  console.log("Original list: "); printList(last);  // Delete the last node last = deleteLastNode(last);  console.log("List after deleting last node: "); printList(last); 

Output
Original list: 2 3 4  List after deleting last node: 2 3  

Time Complexity: O(N)
Auxiliary Space: O(1)


Next Article
Deletion from a Circular Linked List

H

Harsh Agarwal
Improve
Article Tags :
  • Linked List
  • DSA
  • circular linked list
Practice Tags :
  • circular linked list
  • Linked List

Similar Reads

    Deletion in Doubly Circular Linked List
    We have discussed the doubly circular linked list introduction and its insertion.Let us formulate the problem statement to understand the deletion process. Given a ‘key’, delete the first occurrence of this key in the circular doubly linked list. Algorithm: Case 1: Empty List(start = NULL) If the li
    15+ min read
    Delete every Kth node from circular linked list
    Delete every kth node from a circular linked list until only one node is left. Also, print the intermediate lists. Examples: Input : n=4, k=2, list = 1->2->3->4 Output : 1->2->3->4->1 1->2->4->1 2->4->2 2->2 Input : n=9, k=4, list = 1->2->3->4->5-
    13 min read
    Insertion in Doubly Circular Linked List
    Circular Doubly Linked List has properties of both doubly linked list and circular linked list in which two consecutive elements are linked or connected by the previous and next pointer and the last node points to the first node by the next pointer and also the first node points to the last node by
    15+ min read
    Deletion at different positions in a Circular Linked List
    tGiven a Circular Linked List. The task is to write programs to delete nodes from this list present at:  First position.Last Position.At any given position i                                                      .Deleting first node from Singly Circular Linked List Examples:   Input : 99->11->2
    15+ min read
    Introduction to Circular Linked List
    A circular linked list is a data structure where the last node connects back to the first, forming a loop. This structure allows for continuous traversal without any interruptions. Circular linked lists are especially helpful for tasks like scheduling and managing playlists, allowing for smooth navi
    15+ min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences