pgm to find middle element of linklist(in efficent manner)

Answer Posted / vishnu

typedef struct LL_tag
{
int data ;
struct LL_tag *next ;
} LL ;

/*Pass a valid singly linked list*/

LL* Mid (LL *head)
{
LL *one, *two ;

one = two = head ;

while (two)
{
two = two->next ;
if (two)
{
two = two->next ;
one = one->next ;
}
else
{
two = NULL ;
}
}
return one ;
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a program to print all permutations of a given string.

647


write a program to display all prime numbers

1461


Differentiate call by value and call by reference?

571


Why do we need arrays in c?

589


Write a program to print fibonacci series without using recursion?

612






What is difference between union All statement and Union?

630


What is sizeof return in c?

619


What are the modifiers available in c programming language?

744


Write a program to implement queue.

668


What does *p++ do? What does it point to?

620


What does *p++ do?

590


The statement, int(*x[]) () what does in indicate?

649


Draw a flowchart to produce a printed list of all the students over the age of 20 in a class .The input records contains the name and age of students. Assume a sentinel value of 99 for the age field of the trailer record

4748


Explain the difference between malloc() and calloc() function?

604


When is the “void” keyword used in a function?

845