commit
8ddbed6724
@ -167,6 +167,22 @@ public class DoublyLinkedList {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the passed node from the current list
|
||||
*
|
||||
* @param z Element to be deleted
|
||||
*/
|
||||
public void deleteNode(Link z) {
|
||||
if(z.next == null){
|
||||
deleteTail();
|
||||
} else if(z == head){
|
||||
deleteHead();
|
||||
} else{ //before <-- 1 <--> 2(z) <--> 3 -->
|
||||
z.previous.next = z.next // 1 --> 3
|
||||
z.next.previous = z.previous // 1 <--> 3
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeDuplicates(DoublyLinkedList l ) {
|
||||
Link linkOne = l.head ;
|
||||
while(linkOne.next != null) { // list is present
|
||||
|
Loading…
Reference in New Issue
Block a user