write c program to find the middle node of a linked list. This is very basic interview question asked generally from fresher. more experience professional also may face this question.

Use concept of Floyd’s Cycle-Finding Algorithm” also known as “The Tortoise and the Hare Algorithm”
  1. Traverse the linked list using two pointers ( slow pointer and fast pointer).
  2. Move slow pointer by one and fast pointer by two.
  3. When the fast pointer will reach to the end of linked list, the slow pointer would have moved exactly half the linked list , thus slow pointer would point to the middle node of the linked list.

 c program to find the middle node of a linked list



Related Contents to follow