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
Can you assign a different address to an array tag?
How can I prevent another program from modifying part of a file that I am modifying?
Can variables be declared anywhere in c?
How do you print an address?
Difference between Shallow copy and Deep copy?
.main() { char *p = "hello world!"; p[0] = 'H'; printf("%s",p); }
What is a shell structure examples?
State the difference between x3 and x[3].
How do you determine whether to use a stream function or a low-level function?
why return type of main is not necessary in linux
What is a constant and types of constants in c?
What are the different types of control structures?
What are void pointers in c?
Why is c called a mid-level programming language?
What is identifier in c?