Find the middle node in the linked list??
(Note:Do not use for loop, count and count/2)
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / kar..
move the front pointer and rear pointer at equal
intervel,these both pointe will meet at one node is middle...
| Is This Answer Correct ? | 2 Yes | 3 No |
U mean without any looping statements r just for loop?????
It can be done in a single traversal using Hare n turtle
method as said above using a for or while loop.....
Without using looping statements d list can't be traversed..
Plz make the question clear.....
| Is This Answer Correct ? | 3 Yes | 10 No |
What are the loops in c?
What does %d do in c?
Are there constructors in c?
Is linux written in c?
how can we use static and extern?and where can we use this?
What is queue in c?
How to print "Hi World" without using semi colon?
main() { char as[] = "\\0\0"; int i = 0; do{ switch( as[i++]) {case '\\' : printf("A"); break; case 0 : printf("B"); break; default : printf("C"); break; }} while(i<3); }
4 Answers Vector, Vector India,
if a five digit number is input through the keyboard, write a program to calculate the sum of its digits. (hint:-use the modulus operator.'%')
A routine usually part of the operation system that loads a program into memory prior to execution a) linker b) loader c) preprocessor d) compiler
who is the editor of 'pokemon'?
How can I call fortran?