Advertisement
Guest User

s

a guest
Apr 24th, 2018
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. static void insertAfter(DNode curr, DNode newNode) { //TODO
  2.         // Pre: curr and newNode are addresses for DNodes
  3.         // Post: newNode is inserted between curr and its next neighbour, i.e.
  4.         // let N be newNode's next neighbour, then: curr.next points to newNode, newNode.next points to N
  5.         // N.prev points to newNode and newNode.prev points to curr.
  6.         // If curr has no next neighbour, then newNode is inserted as the last node after curr.
  7.  
  8.         DNode n = curr.next; //Since the neighbor of the element being inserted will be this nodes next element.
  9.         curr.next = newNode;
  10.         newNode.next = n;
  11.         n.prev = newNode;
  12.         newNode.prev = curr;
  13.         //This is where I am lost. :/
  14.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement