Results 1 to 8 of 8

Thread: LinkedList

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    LinkedList

    It's been a while for me and wondered if someone could refresh my mind:

    what exactly is a linkedlist?
    How does it work?
    Why would you use a LinkedList?

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  2. #2
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    413
    Visual Studio .NET 2005/.NET Framework 2.0

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: LinkedList

    It's a bunch of objects, each with a reference to the next item in the list, so you can navigate from the first to the last by following the chain of references. It's the original way to create a dynamic list, because you can insert an item simply by manipulating a couple of references. .NET collections are easier to use but not necessarily more efficient in execution. The Framework actually has a LinkedList class but I haven't had cause to use it ever.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: LinkedList

    Neither have I, just thought I would learn a bit more and refresh my memory (not linked list type of memory!)

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  5. #5
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: LinkedList

    Sounds to me like that question on your homework just got answered

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: LinkedList

    far from it my friend

    all I can understand is that each element contains a reference to the previous and next element...have i missed something big out of that?

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: LinkedList

    No, that's about it. Each item in the list has two properties: one is the data and the other is a reference to the next item. To be able to access the list you need to keep a reference to the head or first item. From there you can navigate the entire list by following the references in each item and getting the data as you go. Once you find an item with no reference you know you're at the end of the list.

    To add an item you just create a new item and assign it to the reference of the current last item. To insert an item between item N and item N+1 you copy the reference from item N to the new item, so the new item now has a reference to item N+1, and then assign the new item to item N's reference.

    You can also have a double linked list where each item has a reference to its predecessor and successor in the list, so you can navigate both ways.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: LinkedList

    You can create lists of enormous complexity just by adding extra references into your items. So you can end up with circular lists (very useful for expiring data), binary trees, ternary trees, quad trees and so on.

    For large binary trees, its handy to have an extra references for linking to nodes at the same level as the current one but is otherwise not directly connected to it, many optimisations can be made by sacrificing a bit of RAM in order to gain traversal speed.

    Whole books have been written on the basics of linked lists. Knuth's "The art of computer programming" is a fine example.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width