jQuery in Action, 2nd edition*
The moose likes Beginning Java and the fly likes pointers in linked list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "pointers in linked list" Watch "pointers in linked list" New topic
Author

pointers in linked list

Castulo Ruiz
Greenhorn

Joined: May 08, 2009
Posts: 12
currently im working on a doubly linked list and Im not sure what the difference are between

&&


don't they both point at node?

Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Nope. My advise: draw the datastructure on a piece of paper. Then you'll be able to figure it out.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Castulo Ruiz
Greenhorn

Joined: May 08, 2009
Posts: 12
The way im seeing it is that (back = node;) means that back will point at the node.
while (back.next=node) means that 'back' will look at what its pointing at, lets say node2 and make the pointer of node2 point to node.
so im not sure if im seeing this correctly.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Does this picture help?


[Thumbnail for Temp.png]

Ove Lindström
Ranch Hand

Joined: Mar 10, 2008
Posts: 326

Castulo Ruiz wrote:The way im seeing it is that (back = node;) means that back will point at the node.
while (back.next=node) means that 'back' will look at what its pointing at, lets say node2 and make the pointer of node2 point to node.
so im not sure if im seeing this correctly.


In a double linked list, you should always be able to get the next node and the back node. If back gives you the same node as you already had, then you are at the head of the list. If next gives you the same node, then you are at the end of the list.

Some implementations do use NULL as markers for head and tail.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: pointers in linked list
 
Similar Threads
Linked Lists, Nodes, Quicksort
Implement linked list in java
Linked List Implementation in Java - Source Code please?
doubly linked list
delete in a singly linked list