Whats the error in midpoint function
Hey @Namanjain123
In your code for the midpoint function,
The following line is wrong:
while((fast!=NULL) || (fast->next!=NULL))
Instead, you need to write:
while((fast!=NULL) && (fast->next!=NULL))
because basically you’re following the steps:
fast = fast->next;
fast = fast->next;
which is equivalent to fast = fast->next->next;
so for this to be right, fast and fast->next both should not be equal to NULL, else you may get a segmentation error.