Find the middle node in the linked list??
(Note:Do not use for loop, count and count/2)
Answer Posted / kstarmind
Keep two pointers,
1. fast pointer moves two nodes at a time
2. slow pointer moves one node at a time
keep moving both the pointers, once the fast pointer reaches
the end node, your slow pointer would be at middle of the list.
| Is This Answer Correct ? | 47 Yes | 5 No |
Post New Answer View All Answers
When is a “switch” statement preferable over an “if” statement?
What do you mean by scope of a variable in c?
Is array a primitive data type in c?
What is the scope of static variable in c?
What is pointer in c?
What is a buffer in c?
How can you tell whether a program was compiled using c versus c++?
What functions are in conio h?
What is the role of && operator in a program code?
What is structure in c language?
Which is the best website to learn c programming?
How is actual parameter different from the formal parameter?
Why string is used in c?
Explain the difference between the local variable and global variable in c?
how should functions be apportioned among source files?