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
Describe the various concepts related to object oriented programming (oop).
Explain the significance of listiterator.
How do singleton patterns work?
How we can generate random numbers in java?
In how many ways we can do exception handling in java?
How is tree Mirroring implemented?
How do you override a method?
How do you sort objects in java?
From the two, which would be easier to write: synchronization code for ten threads or two threads?
Implement two stacks using a single array.
How can we achieve thread safety in java?
What is string and example?
What is a loop java?
What is a databasemetadata?
What is foreach loop in java?