Java Reference
In-Depth Information
Our linked list now looks like this:
2
3
1
data
2
next
data
4
next
p
5
6
4
data
3
next
data
9
next
/
q
Now that we've used the value of box 4 to reset box 3, we can reset box 4. It's
supposed to point to the node that has
9
in it. Now we can leapfrog over the current
node to which it is pointing:
q = q.next;
Our linked list now looks like this:
2
3
1
data
2
next
data
4
next
p
5
6
4
data
3
next
data
9
next
/
q
Now we just have to reset box 5. In the original picture we would have
referred to box 5 as
q.next
, but now that we've changed the value of
q
, we have to
change the way we refer to this box. We can still get to box 5 by starting with the
variable
p
:
p.next.next.next = null;
Our linked list now looks like this:
2
3
1
data
2
next
data
4
next
p
5
6
4
data
3
next
/
data
9
next
/
q
Search WWH ::
Custom Search