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


Please Help Members By Posting Answers For Below Questions

How can you read a directory in a C program?

647


What do you mean by keywords in c?

621


1. Write a function to display the sum of two numbers in the following ways: By using (i) pass by value (ii) pass by address a. function with argument and with return value b. function with argument and without return value c. without argument , with return value d. without argument , without return value Note: Use pass by address.

2335


What is type qualifiers?

655


What is "Duff's Device"?

699






What does == mean in texting?

659


How can I call system when parameters (filenames, etc.) Of the executed command arent known until run time?

588


Is there a way to compare two structure variables?

615


How can you be sure that a program follows the ANSI C standard?

1124


What is conio h in c?

622


What is meant by preprocessor in c?

530


An application package has been provided to you without any documents for the following application. The application needs to be tested. How will you proceed?

665


Is there any possibility to create customized header file with c programming language?

619


What does the c preprocessor do?

615


Define circular linked list.

568