Sunday, July 26, 2009

Can someon please provide me with a brief introduction about Linked List in C++?

I really need it asap! Thanks!

Can someon please provide me with a brief introduction about Linked List in C++?
class linkedlist


{


int data;


linkedlist *ptr;


append(...);


delete(...);


find(...)


}
Reply:Former answer is right but... it is not a C++ (STL) list. Read this:


http://www.sgi.com/tech/stl/List.html
Reply:A linked list is a chain of structs or records called nodes. Each node has at least two members, one of which points to the next item or node in the list! These are defined as Single Linked Lists because they only point to the next item, and not the previous. Those that do point to both are called Doubly Linked Lists or Circular Linked Lists. Please note that there is a distinct difference betweeen Double Linked lists and Circular Linked lists. I won't go into any depth on it. According to this definition, we could have our record hold anything we wanted! The only drawback is that each record must be an instance of the same structure. This means that we couldn't have a record with a char pointing to another structure holding a short, a char array, and a long. Again, they have to be instances of the same structure for this to work. Another cool aspect is that each structure can be located anywhere in memory, each node doesn't have to be linear in memory!





all of this was taken from a tutorial from the website listed in the source. It makes learning about linked lists not so intimidating. They're very useful though.


No comments:

Post a Comment