JAVA Program for Deletion from End of a Doubly Linked List

JAVA Program to Delete a Node from the End

Each variation of Data Structure has some basic list of operations that can be performed on them one of them is Deletion from Various Nodes. Here in this page we’ll take a look at the detailed explanation of the deletion from end of a doubly linked list.

deletion from end in doubly linked list

Steps to be followed while deleting a Node from end of a Doubly Linked List

  • Check for the presence of Node in the List, if there exists some Nodes, Continue.
  • Now, to Delete a node from the end of the Doubly Linked List, we’ll have to redirect links of the Linked List.
  • Let the length of the List = i.
  • First of all the next pointer of the (i-1)th node of the Linked List will now be re-directed towards the Tail of the Linked List.

Example:

If we have a list (10 –> 20 –> 30 –> 40 –> 50) and we have to Delete the node storing 50. So after Deleting the Last Node. Updated Linked list will be (10 –> 20 –> 30 –>40) . We will be learning more about the whole process in the explanation below.

Deletion from end in a doubly linked list

Algorithm to be used for the Deletion of a Node from the End of a Doubly Linked List

  • IF(HEAD == NULL)
    • RETURN 
  • ELSE IF(HEAD != TAIL)
    • HEAD = HEAD.NEXT
    • TAIL.NEXT = NULL 
  • ELSE 
    • HEAD = TAIL = NULL 

 

Java Program for deleting a node from end of a Doubly Linked List

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

Doubly Linked List

  • Introduction to Doubly Linked list in Data Structure
    Click Here
  • Doubly Linked List in –
    C | C++ | Java
  • Insertion in doubly linked list –
    C | C++ | Java
  • Insertion at beginning in doubly linked list –
    C | C++ | Java
  • Insertion at end in doubly linked list –
    C | C++ | Java
  • Insertion at nth node in doubly linked list –
    C | C++ | Java
  • Deletion in doubly linked list  –
    C | C++ | Java
  • Deletion from beginning in doubly linked list :
  • Deletion from nth in doubly linked list :
    C | C++ | Java
  • Deletion from end in doubly linked list :
    C | C++ | Java
  • Insertion and Deletion in a  doubly linked list :
    C | C++ | Java
  • Insertion in the middle in a  doubly linked list :
    C | C++ | Java

Doubly Linked List