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
What is the time and space complexities of merge sort and when is it preferred over quick sort?
Are pointers really faster than arrays?
why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???
What is non linear data structure in c?
Tell me about low level programming languages.
Write a factorial program using C.
What are the 5 types of inheritance in c ++?
What is static function in c?
Why c is called top down?
write a program to copy the string using switch case?
What are the differences between new and malloc in C?
What is the code for 3 questions and answer check in VisualBasic.Net?
in linking some of os executables are linking name some of them
Explain what are global variables and explain how do you declare them?
What’s the special use of UNIONS?