PDA

View Full Version : Library Books Bore Me....



Jackrawl
05-01-2008, 01:53 AM
I've checked out 7-8 C++ programming books, all of which I have read. None of them properly explain Nodes or Linked Lists outside of expanded form. If there are any C++ Gurus here, I'd appreciate a little explanation in that area.

Yakman
05-01-2008, 10:34 AM
linked list is one of the fundamental data structures, and can be used to implement other data structures. It consists of a sequence of nodes, each containing arbitrary data fields and one or two references ("links") pointing to the next and/or previous nodes. The principal benefit of a linked list over a conventional array is that the order of the linked items may be different from the order that the data items are stored in memory or on disk, allowing the list of items to be traversed in a different order. A linked list is a self-referential datatype because it contains a pointer or link to another datum of the same type. Linked lists permit insertion and removal of nodes at any point in the list in constant time,[1] but do not allow random access. Several different types of linked list exist: singly-linked lists, doubly-linked lists, and circularly-linked lists.

Linked lists can be implemented in most languages. Languages such as Lisp and Scheme have the data structure built in, along with operations to access the linked list. Procedural or object-oriented languages such as C, C++, and Java typically rely on mutable references to create linked lists. (http://en.wikipedia.org/wiki/Linked_list)

Richard
05-01-2008, 04:59 PM
If you find that books bore you, then just use the tutorials microsoft provide, they are suprisingly helpful (that if you have visual c++ by microsoft)

If you aren't using Mcrosoft Visual C++ 2008 Express Edition (bit of a mouthful...) then can you tell me? :D

Jackrawl
05-02-2008, 09:53 PM
If you find that books bore you, then just use the tutorials microsoft provide, they are suprisingly helpful (that if you have visual c++ by microsoft)

If you aren't using Mcrosoft Visual C++ 2008 Express Edition (bit of a mouthful...) then can you tell me? :D

I am using Visual 2008 EE, but it's always a pain to use their sites. For some reason they always lag. =/

linked list is one of the fundamental data structures, and can be used to implement other data structures. It consists of a sequence of nodes, each containing arbitrary data fields and one or two references ("links") pointing to the next and/or previous nodes. The principal benefit of a linked list over a conventional array is that the order of the linked items may be different from the order that the data items are stored in memory or on disk, allowing the list of items to be traversed in a different order. A linked list is a self-referential datatype because it contains a pointer or link to another datum of the same type. Linked lists permit insertion and removal of nodes at any point in the list in constant time,[1] but do not allow random access. Several different types of linked list exist: singly-linked lists, doubly-linked lists, and circularly-linked lists.

Linked lists can be implemented in most languages. Languages such as Lisp and Scheme have the data structure built in, along with operations to access the linked list. Procedural or object-oriented languages such as C, C++, and Java typically rely on mutable references to create linked lists. (http://en.wikipedia.org/wiki/Linked_list)

Right, but what is the real advantage in using them? I know that they use dynamic memory, but why not use strings? Do they store single characters, one at a time, can they work with bitmaps?

boberman
05-06-2008, 04:00 PM
For linked lists, you get some pretty dang good sequential speed along with dynamic growth. That is their biggest benifit. The downside is that random access sucks (You have to go through an unknown amount of data members when doing a search, linked lists have extra overhead which makes this somewhat slow).

Nodes are useful in creating data structures of with unique attributes. A linked list uses a node. A good example of this is the tree structure. one node could link to 100 nodes which in turn link to 10 or maybe even 1 or 2, that makes the structure very dynamic and descriptive (Look up A* pathfinding for one of the bigger uses of nodes)

A node can be described as an objects which has one or more of its data members pointing to another object of the same type (Actually, I don't know that they have to be the same type...) a linked list is a form of arranged nodes.

Maybe another way to think of nodes is in a geneology sence. I have a family, two parents. Some day I hope to have children. When asked who my parents are I can point to my parents, they in turn asked the same question can point to their parents. However, if I was asked for my parents parents I wouldn't be required to know that (Ok, so I do, but nodes dont). We are all humans but at the same time have very different attributes and qualities.

Hope this kind of helps.