pointers to elements in a Linked-List?

Discussion in 'C Programming' started by Paminu, Oct 12, 2005.

  1. Paminu

    Paminu Guest

    I have a Linked-List and would like to create pointers to elements in this
    list.

    e.g I would like two pointers that point to each of their elements in the
    Linked-List. But there should always be exactly 5 nodes between these
    pointers.

    Does this make any sense or are there some more efficient way to access
    certain elements in a Linked-List?
    Paminu, Oct 12, 2005
    #1
    1. Advertising

  2. Paminu

    Eric Sosman Guest

    Paminu wrote On 10/12/05 15:26,:
    > I have a Linked-List and would like to create pointers to elements in this
    > list.
    >
    > e.g I would like two pointers that point to each of their elements in the
    > Linked-List. But there should always be exactly 5 nodes between these
    > pointers.
    >
    > Does this make any sense or are there some more efficient way to access
    > certain elements in a Linked-List?


    First: This isn't a C question. It might be a data
    structure or algorithm question, in which case comp.programming
    would be a better forum.

    Second: The question isn't well-posed. No arrangement
    of data is more or less efficient than any other until you
    consider the operations that are to be performed. What are
    you planning to do, and why do you expect these extra pointers
    to be helpful? (Please *don't* answer: Your question still
    isn't about C and doesn't belong here; my point is to show
    you that even if you find an appropriate forum your question
    as it stands is not a good one.)

    Third: Google for "search tree" and/or "skip list."

    --
    Eric Sosman, Oct 12, 2005
    #2
    1. Advertising

  3. Paminu

    Mabden Guest

    "Eric Sosman" <> wrote in message
    news:dijp2e$k5h$...
    >
    >
    > Paminu wrote On 10/12/05 15:26,:
    > > I have a Linked-List and would like to create pointers to elements

    in this
    > > list.
    > >
    > > e.g I would like two pointers that point to each of their elements

    in the
    > > Linked-List. But there should always be exactly 5 nodes between

    these
    > > pointers.
    > >
    > > Does this make any sense or are there some more efficient way to

    access
    > > certain elements in a Linked-List?

    >
    > First: This isn't a C question. It might be a data
    > structure or algorithm question, in which case comp.programming
    > would be a better forum.


    It's an interview question I was once asked. "How do you find the
    fifth-from-last item in a singly-linked list?" Why they always choose 5,
    I don't know.

    You can always tell homework and interview questions by the artificial
    contraints on the problem. I mean, why isn't it a doubly-linked list if
    they need to go backwards? Why not use a array and jump to the correct
    offset?

    --
    Mabden
    Mabden, Oct 23, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Ritchey
    Replies:
    7
    Views:
    463
    emerth
    Jul 10, 2003
  2. Chris Ritchey

    Generating a char* from a linked list of linked lists

    Chris Ritchey, Jul 9, 2003, in forum: C Programming
    Replies:
    7
    Views:
    452
    emerth
    Jul 10, 2003
  3. fool
    Replies:
    14
    Views:
    491
    Barry Schwarz
    Jul 3, 2006
  4. Sean
    Replies:
    2
    Views:
    629
    loufoque
    Sep 24, 2006
  5. joshd
    Replies:
    12
    Views:
    652
    John Carson
    Oct 2, 2006
Loading...

Share This Page