i am not able to run the opertaion of midpoint . Pls help me with code.
Reagrding the midpoint
Please share your code
int midpoint()
{
if(head==NULL || head->next==NULL)
{
if(head==NULL)return -1; //added this
return head->data; //updated this
}
NODE *slow=head;
NODE *fast=head->next;
while(fast!=NULL && fast->next!=NULL)
{
fast=fast->next->next;
slow=slow->next;
}
return slow->data; //updated this
}