Difference between revisions of "Linked List"

From CDOT Wiki
Jump to: navigation, search
(ABOUT: Why are we talking about linked lists?)
(ADVANTAGES: So, what's so good about a linked list?)
Line 7: Line 7:
  
 
== ADVANTAGES: So, what's so good about a linked list? ==
 
== ADVANTAGES: So, what's so good about a linked list? ==
-incomplete-
+
Linked Lists are large sprawling entities and can be extremely useful.
 +
=== Non-Sequential Element Map ===
 +
Linked Lists are like arrays except that where the elements of an array are laid out in sequential order in memory, the elements of a Linked List are all over the place with one element pointing to the next. This design is more flexible in that it allows the list to dynamically grow over time as opposed to being locked into a certain number of elements since the time of initialization.
 +
=== Dynamic Insertion ===
 +
Linked Lists also handle insertion at the midpoint much more gracefully and efficiently than an array. In order for an array to insert an element at the middle of it, it has to shift every subsequent element down the line by one. But what if the array is full? Then even worse, a whole new bigger array must be allocated! The exact sequence goes something like this:
 +
# The first part of the old array must be copied into the new bigger array.
 +
# Then the element to be inserted must be added to the current tail of the bigger array.
 +
# Then finally, the second part of the old array must be added to the bigger array.
 +
<br/>
 +
This is a very taxing process. With a linked list on the other hand, a node containing the data (or a reference to it) must be created then the two nodes that surround the required position must set their <code>next</code> and <code>previous</code> references to it, respectively. That's all! There is much less processing and much less brute force. However, this process entails considerable amounts of thought and overhead as we will see soon.
 +
 
 
== DISADVANTAGES: Well there has to be a downside! ==
 
== DISADVANTAGES: Well there has to be a downside! ==
 
-incomplete-
 
-incomplete-

Revision as of 00:25, 20 November 2009

Linked Lists: A Conceptual Look

ABOUT: Why are we talking about linked lists?

I've been told that many of us are struggling with the creation of a successful, working Linked List. That's why this page is here.

This page is aimed at giving a conceptual overview of the uses and design elements of a linked list. Linked lists are flexible and powerful and can prove to be very useful tools in the arsenal of a UI designer or implementer. Therefore, having a linked list handy would make most hackers' lives a whole lot better :)

With that being said, read on!

ADVANTAGES: So, what's so good about a linked list?

Linked Lists are large sprawling entities and can be extremely useful.

Non-Sequential Element Map

Linked Lists are like arrays except that where the elements of an array are laid out in sequential order in memory, the elements of a Linked List are all over the place with one element pointing to the next. This design is more flexible in that it allows the list to dynamically grow over time as opposed to being locked into a certain number of elements since the time of initialization.

Dynamic Insertion

Linked Lists also handle insertion at the midpoint much more gracefully and efficiently than an array. In order for an array to insert an element at the middle of it, it has to shift every subsequent element down the line by one. But what if the array is full? Then even worse, a whole new bigger array must be allocated! The exact sequence goes something like this:

  1. The first part of the old array must be copied into the new bigger array.
  2. Then the element to be inserted must be added to the current tail of the bigger array.
  3. Then finally, the second part of the old array must be added to the bigger array.


This is a very taxing process. With a linked list on the other hand, a node containing the data (or a reference to it) must be created then the two nodes that surround the required position must set their next and previous references to it, respectively. That's all! There is much less processing and much less brute force. However, this process entails considerable amounts of thought and overhead as we will see soon.

DISADVANTAGES: Well there has to be a downside!

-incomplete-

DESIGN: What is a "linked List"?

-incomplete-

ELEMENTS: Nodes are everything!

-incomplete-

SEEK: Search speeds and indexing

-incomplete-

FLEXIBILITY: Data Types

-incomplete-