I have a singly linked list which has 100 node. I need to check this linked list circular or not?
It can be achieved by traversing list and need to check last node link field equal to head.
struct node *temp1, *temp2;
while(i != 100) {
temp2 = temp1->link;
if(temp2==head) {
printf("circular");
break;
else
temp1=temp1->link;
i++;
}
This method will take maximum of 100 iteration. I want to reduce this to half, i mean by 50 iteration i need to achieve this.
Is it possible to do this? If yes, how we can do this?