Results 1 to 3 of 3

Thread: How do we find out if a linked-list has an end?

  1. #1

    Thread Starter
    Banned
    Join Date
    May 2013
    Posts
    11

    How do we find out if a linked-list has an end?

    hiiii friends, please tell me

    How do we find out if a linked-list has an end?

  2. #2
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: How do we find out if a linked-list has an end?

    The only logical way would be to traverse it and when the next pointer of the current element is null, it means that the current element is the last element.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: How do we find out if a linked-list has an end?

    I started to say that all linked lists have an end and a beginning... commonly known as a head and tail... but then I realized it's possible to have a circular linked list... where the tail points to the head... so it just goes around and around and around... if that's the case then you need to start somewhere, mark it, or some how store where you are... then go to the next item in the list... if you hit a NULL (or Nothing in VB) pointer to the next element, as Niya noted, you've reached the end. IF you have a circular list though and come back around to where you started, then... well, you have a circular list and there is no end.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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