Tell how to check whether a linked list is circular ?
Submitted by: AdministratorCreate 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”);
}
}
Submitted by: Administrator
while (pointer1)
{
pointer1 = pointer1->next;
pointer2 = pointer2->next; if (pointer2) pointer2=pointer2->next;
if (pointer1 == pointer2)
? ? ? ? ? ? {
print (”circularn”);
}
}
Submitted by: Administrator
Read Online Data Structures Job Interview Questions And Answers
Top Data Structures Questions
☺ | What is data structure? |
☺ | List out the areas in which data structures are applied extensively? |
☺ | If you are using C language to implement the heterogeneous linked list, what pointer type will you use? |
☺ | What is the data structures used to perform recursion? |
☺ | What are the methods available in storing sequential files ? |
Top Databases Programming Categories
☺ | RDBMS Interview Questions. |
☺ | SQL Interview Questions. |
☺ | SSRS Interview Questions. |
☺ | Sybase Interview Questions. |
☺ | Database Administrator (DBA) Interview Questions. |