Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Data Structures Interview Questions and Answers

Question: Tell how to check whether a linked list is circular ?
Answer: 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 (?circularn?);
}
}
Is it helpful? Yes No

Most helpful rated by users:

©2024 WithoutBook