Answer Posted / pradip mishra(b-tech it)
Create two pointers, each set to the start of the list.
Update each as follows:
while (pointer1) {
pointer1 = pointer1->next;
pointer2 = pointer2->next; if (pointer2)
pointer2=pointer2->next;
if (pointer1 == pointer2) {
print (\"circular\n\");
}
}
If a list is circular, at some point pointer2 will wrap
around and be either at the item just before pointer1, or
the item before that. Either way, it?s either 1 or 2 jumps
until they meet.
Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
what are the methods in object?
Is java map thread safe?
What is the return type of the main method?
What is the difference between C++ and Java and your preferences?
What is the default value of byte datatype in java?
What happens if an exception is throws from an object's constructor?
What is string syntax?
What is difference between == equals () and compareto () method?
What are the different types of methodologies?
What do you know about the garbage collector?
Is null in java?
What is the Concept of Encapsulation in OOPS
What is an empty class? What functionality does it offer in Java?
What is default size of arraylist in java?
Can a class have 2 constructors?