sardi kuka
0
Q:

fast and slow pointer approach to find the middle of the linked list

struct node* findMiddle(struct node* head){
  if(head == NULL)exit(1);
  struct node* slow;
  struct node* fast;
  fast = slow = head;
  while(fast -> next != NULL && fast != NULL && fast -> next -> next != NULL){
    slow = slow -> next;
    fast = fast -> next -> next;
  }
  return slow;
}  
1

New to Communities?

Join the community