![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Feb 2006
Posts: 214
Rep Power: 0
![]() |
Linked Lists
I've read the section from my book on linked lists. The thing is though I kinda grasp the entire concept of it. I just don't know why would you use them in a real life situation.
I find that the book Sam's C++ in 24 hours doesn't do a good job of explaining linked lists. So please any help would be greatly appreciated. |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Jan 2006
Location: UK
Posts: 214
Rep Power: 3
![]() |
A linked list consists of a node of two parts. Firstly the data that is to be stored in the list, then secondly a field to indicate where the next node in the list is located. This allows items to be added to the list dynamically, unlike static lists i.e in the form of arrays.
Dynamic lists have 2 main advantages over static lists. 1). Static lists such as arrays cannot be made longer on demand. 2). Saves waste of memory (i.e array[100]) when the actual is short (only 10 items that need to be added to the list, leaving 90 wasted allocated fields in memory) sorry, I cant elaborate any further or making myself clear too well, as I am late for the pub and need to dash... if you need anymore help send me your email and I can send you some lecture slides i have on linked lists if you like. |
|
|
|
|
|
#3 | |
|
Hobbyist Programmer
Join Date: Feb 2006
Posts: 214
Rep Power: 0
![]() |
Quote:
I'm up for all the help i can get so if anyone has anything else to add please feel free to write it. |
|
|
|
|
|
|
#4 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
Well if you search the forum or even try to take a look at the C forum you would see lots of threads about the subject. Like Seif said, those two are the main advantages.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
|
#5 |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5
![]() |
well, the text you have does only provide a cursory glance at singly-linked lists.
however, two things you can do to help with that is to copy and play with the code, and examine the pictorial representations of what's really going on there with the data structure pointing to the next one and so on. i used one of their books to try and generate 10,000 random numbers, sort them into a list from highest to lowest, and print the results. the conclusion of that experiment led to marginal progress and i would suggest grounding yourself in the other subjects in that book and try again. (i.e. skip it). this topic is usually covered only after you have spent a lot of time on the basics. i think the pictures helped me the most. draw diagrams, modify the code, etc.
__________________
i put on my robe and wizard hat... Have you ever heard of Plato, Aristotle, Socrates?...Morons. |
|
|
|
|
|
#6 | ||
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
Quote:
Quote:
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
||
|
|
|
|
|
#7 |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5
![]() |
indeed, google rules.
__________________
i put on my robe and wizard hat... Have you ever heard of Plato, Aristotle, Socrates?...Morons. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|