Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DoublyLinkedList.java #3

Open
VipulGupta09 opened this issue Apr 27, 2021 · 0 comments
Open

DoublyLinkedList.java #3

VipulGupta09 opened this issue Apr 27, 2021 · 0 comments

Comments

@VipulGupta09
Copy link

In class DoublyLinkedList, the method detachNode(),
Here we need to check the node that we are deleting having prev and next not null as:
case 1 :
if(node.prev!=null){
node.prev.next = node.next;
}else{
dummyHead = node.next; // if the node is head then we need to move the head .
}
case 2 :
if(node.next!=null){
node.next.prev = node.prev;
}else{
dummyTail = node.prev; // if the node is tail then we need to move the tail.
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant