Archive for the ‘Tutorials’ Category

Linked Lists

In C Tidbits, Data Structures in C/C++, Pointers & Callbacks, Tutorials on April 12, 2007 at 2:55 pm

Linked Lists Basics
[Download this tutorial as linked lists tutorial , for updated conetnt and comments, generate a new pdf with the option which is present below the post]

What are Linked Lists?
Linked lists store collections of data like arrays.  Linked lists are chain of records/nodes, one record/node points to the next. Record holds the data.

Why Linked Lists?
There are several  disadvantages with arrays, here are some…
1) The size of the array is fixed. Most often this size is specified at compile time however the size of the array can be deferred until the array is created at runtime (from heap), but after that it remains fixed. This causes to waste memory eventhough e may not use.
2) Inserting new elements at the front is potentially expensive because existing elements need to be shifted over to make room.
3)When array was full, to insert more data, it need to be resized, this operation is quite expensive, even may not be possible if in case memory got fragmented.
Linked lists performs well where arrays fail to do it.
Please refer http://www.refcode.net/2013/02/linked-lists.html