How to find middle element in link list in C program? This is one of the frequently asked interview question specially for less than two years of experience programmer including freshers. Let suppose we have a link list 5 6 7 8 9 , write a c program to print its middle element.

How to find middle element in link list in C programSolution:

Use two pointers to traverse link list, one as “fast” and  second as “slow”.  The fast pointer will increment by two and slower will increment by one. When the list will end the slow pointer will be at the middle.

 

Output:
The list is




Related Contents to follow