Answer to Question #300569 in Java | JSP | JSF for Ganesh

Question #300569

Write an algorithm to delete a node at end of the doubly linked list and create the logic for the same

1
Expert's answer
2022-02-22T13:06:53-0500
public class Main {
    Node head;
    Node tail;

    public void deleteTail() {
        if (tail != null) {
            if (tail.prev == null) {
                head = null;
                tail = null;
            } else {
                tail = tail.prev;
                tail.next = null;
            }

        }
    }

    static class Node {
        Node next;
        Node prev;
        int data;

        public Node(int data) {
            this.data = data;
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS