struct node
{
int info;
struct node *next;
};
struct node* getMiddleNode(struct node **start)
{
struct node *middle = *start;
struct node *fast_ptr = *start;
if(*start != NULL)
{
while((fast_ptr->next) !=NULL && (fast_ptr->next->next) != NULL)
{
fast_ptr = fast_ptr->next->next;
middle = middle->next;
}
}
return middle ;
}
No comments:
Post a Comment