Be a Supporter!

Linked Lists

  • 236 Views
  • 3 Replies
New Topic Respond to this Topic
Tygerman
Tygerman
  • Member since: Aug. 16, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Linked Lists 2011-04-12 17:04:29 Reply

Is it possible for a node in a linked list to point to more than one node

Also, is it possible for a node to have more than one node pointing to it?


BBS Signature
tenentenen
tenentenen
  • Member since: Apr. 13, 2009
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to Linked Lists 2011-04-12 17:23:20 Reply

At 4/12/11 05:04 PM, Tygerman wrote: Is it possible for a node in a linked list to point to more than one node

Also, is it possible for a node to have more than one node pointing to it?

This isn't really about flash, but programming and implementation in general, but I'll help you out.

Nodes can traditionally point to either one or two other nodes, which are called singly linked lists, and doubly linked lists. The nodes for each are designed differently.

Singly Linked Lists:
-Nodes have two internal objects. one is the data, and the other is a pointer to the next Node object.
-Can be easily traversed forwards, because there is a Direct linke from each node to the next, but harder to go backwards, because there is no way of knowing which node this node has been linked from.

Doubly Linked Lists:
-Nodes have 3 internal Objects. The data, a pointer to the previous node, and a pointer to the next node.
-These lists can be easily traversed either forwards or backwards, because there is an explicit reference both ways.

If you link a node to two "next nodes" and one previous nodes, you create a sort of data tree, and it is no longer really a "List." It's all about what you want to do.

Picture below to help you understand.

Linked Lists

Yannickl88
Yannickl88
  • Member since: Nov. 2, 2008
  • Offline.
Forum Stats
Member
Level 11
Game Developer
Response to Linked Lists 2011-04-12 17:24:50 Reply

At 4/12/11 05:04 PM, Tygerman wrote: Is it possible for a node in a linked list to point to more than one node

Also, is it possible for a node to have more than one node pointing to it?

If by node you mean internal node, then yes... doesn't it already do so with the previous and next pointers?

Not sure why you ask this though, seems more like a basic programming homework question too me :p.


You can ask me anything about AS3, PHP, HTML, CSS, JavaScript, Ruby, Python, Java, XML, JSON, Photoshop, and some more....

Yannickl88
Yannickl88
  • Member since: Nov. 2, 2008
  • Offline.
Forum Stats
Member
Level 11
Game Developer
Response to Linked Lists 2011-04-12 17:26:28 Reply

Ah, nevermind me, Tenentenen pretty much gave a full answer.


You can ask me anything about AS3, PHP, HTML, CSS, JavaScript, Ruby, Python, Java, XML, JSON, Photoshop, and some more....