Deletion in Circular Linked List

&& operator in C

JAVA Program to Delete a Node of a Circular Linked List

A Circular Linked List is collection of data elements where each element points towards the next element and the last Element points towards the First Element Hence forming  a Loop.            Below on this page we will learn about Circular Linked List Deletion in java.

Algorithm for deletion from beginning of a circular linked list

  • deleteFirst()
  • IF head == null
    • return
  • ELSE IF head != tail
    • head = head -> next
    • tail -> next = head
  • ELSE
    • head = tail = null
Deletion in circular Linked List from Beginning
public void deleteFirst() {  
        if(head == null) {  
            return;  
        }  
        else {  
            if(head != tail ) {  
                head = head.next;  
                tail.next = head;  
            }  
            else {  
                head = tail = null;  
            }  
        }  
    }  

Algorithm for deletion from last of a circular linked list

  • deleteLast()
  • IF head == null
    • return
  • ELSE IF head != tail
    • Node current = head
    • WHILE current->next != tail
      • current = current-> next
      • tail = current;
      • tail -> next = head
  • ELSE
    • head = tail = null
Deletion from last in Singly Linked List
public void deleteLast() {
        if(head == null) {
            return;
        }
        else {
            if(head != tail ) {
                Node current = head;
                while(current.next != tail) {
                    current = current.next;
                }
                tail = current;
                tail.next = head;
            }
            else {
                head = tail = null;
            }
        }
    }

Algorithm for deletion from last of a circular linked list

  • deleteLast()
  • IF head == null
    • return
  • ELSE
    • WHILE (–n>0)
      • previous = temp;
      • temp = temp.next;
    • previous.next = temp.next;
Deletion in circular Linked List from Nth node

Code for deletion of a node in circular Linked List in Java

Prime Course Trailer

Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others

Checkout list of all the video courses in PrepInsta Prime Subscription

Checkout list of all the video courses in PrepInsta Prime Subscription

Circular Linked List

  • Introduction to Circular Linked List
    Click Here
  • Circular Linked List Applications
    Click Here
  • Circular Linked List in –
    C | C++ | Java
  • Insertion in Circular Linked List –
    C | C++ | Java
  • Insertion at the beginning–
    C | C++ | Java
  • Insertion at the end –
    C | C++ | Java
  • Insertion at nth position –
    C | C++ | Java
  • Deletion in Circular Linked List –
    C | C++ | Java
  • Deletion from beginning in Circular Linked List –
    C | C++ | Java
  • Deletion from nth position in Circular Linked List –
  • Deletion from end in Circular Linked List –
    C | C++ | Java
  • Insertion and Deletion in Circular Linked List – C | C++ | Java
  • Split a Circular Linked List in two halves –
    C | C++ | Java
  • Count nodes in Circular Linked List –
    C | C++ | Java
  • Sorted Insert In Circular Linked List –
    C | C++ | Java
  • Insertion in the middle in Circular Linked List –
    C | C++ | Java

Circular Linked List