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



Find the middle node in the linked list?? (Note:Do not use for loop, count and count/2)..

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

Find the middle node in the linked list?? (Note:Do not use for loop, count and count/2)..

Answer / om

just use recursion .....it's simple......

Is This Answer Correct ?    4 Yes 3 No

Find the middle node in the linked list?? (Note:Do not use for loop, count and count/2)..

Answer / santhoshr

It wont work exactly if the no of nodes is not given!!! So
better answer is having two pointers from first itslf.
And like this , another question is there,
to find the pth node from last!! That too haas the same logic!!!

Is This Answer Correct ?    2 Yes 1 No

Find the middle node in the linked list?? (Note:Do not use for loop, count and count/2)..

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

Find the middle node in the linked list?? (Note:Do not use for loop, count and count/2)..

Answer / dhr

it also works

Is This Answer Correct ?    1 Yes 3 No

Find the middle node in the linked list?? (Note:Do not use for loop, count and count/2)..

Answer / vadivel

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

Post New Answer

More C Interview Questions

Write a program to add the following ¼+2/4+3/4+5/3+6/3+... (Like up to any 12 no.s)

1 Answers   HTC,


Why doesn't the code "a[i] = i++;" work?

4 Answers  


Derive the complexity expression for AVL tree?

1 Answers  


What is scope of variable in c?

0 Answers  


what is y value of the code if input x=10 y=5; if (x==10) else if(x==9) elae y=8; a.9 b.8 c.6 d.7

4 Answers   TCS,






Explain what happens if you free a pointer twice?

0 Answers  


What is a symbolic constant?

1 Answers  


Hai,I have done with my bachelor of commerce and planing to ms,please suggest me how to convince vo for shifting from commerce to computers. Visa on 8 DEC 2014  Npu university

0 Answers  


declare afunction pointer to int printf(char *)?

1 Answers   HCL,


yogesh patil in dell

3 Answers   DELL,


define function

4 Answers   Assurgent, Sonata,


Explain what are the __date__ and __time__ preprocessor commands?

0 Answers  


Categories