pointers to elements in a Linked-List?

P

Paminu

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?
 
E

Eric Sosman

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."
 
M

Mabden

Eric Sosman said:
Paminu wrote On 10/12/05 15:26,:

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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top