conceptual question

I am a new student to Java with very little experience in any programming and have been assigned a project to create a singly linked circular list with no beginning or end.

My question is conceptual: If the list has no beginning or end, how do I "enter" the list to search, delete or insert. Basically, how do I tell the program where to begin?

[357 byte] By [sophie07a] at [2007-11-27 6:53:12]
# 1

Instead of being a line like a regular LL, yours will be a circle, basically the same thing, but with the tail linked to the head. Since if you start in any place and keep iterating, you'll end up back at where you started, it doesn't matter where you start. Think of how you would count the number of horses on a carousel. Would it matter which one you started with? No, just start somewhere and keep counting until you get to the one you started on.

Editid for speling

Message was edited by:

hunter9000

hunter9000a at 2007-7-12 18:27:55 > top of Java-index,Java Essentials,New To Java...
# 2
you will need a reference (think of it as a pointer) to at least one node within the linked list. you can think of this reference will be beginning of your list from which you can traverse the list.
paul.y.wanga at 2007-7-12 18:27:55 > top of Java-index,Java Essentials,New To Java...
# 3
It just means that you can start at any point. (Like where you last inserted an element, or where your last search terminated)
kajbja at 2007-7-12 18:27:55 > top of Java-index,Java Essentials,New To Java...
# 4

http://en.wikipedia.org/wiki/Circular_list#Circularly-linked_list

In that picture, the "head" of the list is still the node with 12 in it, just like it would be in a regular LL. The "tail" is still the 37 node. The only difference is that the tail is linked to the head. Just like you would start a search at the head in a regular LL, you could start it there for the circular one.

hunter9000a at 2007-7-12 18:27:55 > top of Java-index,Java Essentials,New To Java...
# 5
Think of it as an ellipse with a height = to the number of elementsand the width -> 0.
TuringPesta at 2007-7-12 18:27:55 > top of Java-index,Java Essentials,New To Java...
# 6
What if the list has just been created and there is no data in it so all references are null?Would I use something like current=current.next as a starting point?
sophie07a at 2007-7-12 18:27:55 > top of Java-index,Java Essentials,New To Java...
# 7
> What if the list has just been created and there is> no data in it so all references are null?> > Would I use something like current=current.next as a> starting point?current == null ?
Hippolytea at 2007-7-12 18:27:55 > top of Java-index,Java Essentials,New To Java...
# 8

> What if the list has just been created and there is

> no data in it so all references are null?

All references? You will just have one, the one that references any element once you have added an element to the list.

>

> Would I use something like current=current.next as a

> starting point?

No

current = null;

kajbja at 2007-7-12 18:27:55 > top of Java-index,Java Essentials,New To Java...
# 9
Okay, I am starting to get the picture. Thanks to all for entertaining my question and lack of knowledge.
sophie07a at 2007-7-12 18:27:56 > top of Java-index,Java Essentials,New To Java...