'If I want to create method insertMiddle(E e) what should i do? (DoublyLinkedList)?
first of all, i tried to create a inserMiddle(E e) method in Generic type at doublyLinkedList class;
Assume the list has even number of nodes.
public void insertMiddle(E e) {
NodeDoubly current = header;
NodeDoubly middle = new NodeDoubly(e);
for(int i =0; i < size()/2 -1 ;i++) {
current = current.next;
}
middle.next = current.next.next;
middle.prev = current.next;
size++;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
