pgm to find middle element of linklist(in efficent manner)
Answer Posted / ashwini
struct node
{
int data;
struct node *ptr;
};
struct node mid_element(struct node* head)//since we pass addr
{
int count=0,n_count,i=0;
struct node* temp,*mid;
temp=mid=head;
while(temp -> ptr != NULL)
{
count++;
temp = temp->otr;
}
count++;
if(count % 2)
{
n_count = (count/2)+1;
for(i=0 ; i<n_count ; i++)
mid = mid -> ptr;
}
return mid;
}
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
what are the facialities provided by you after the selection of the student.
How can you tell whether a program was compiled using c versus c++?
Can you mix old-style and new-style function syntax?
Write an efficient algo and C code to shuffle a pack of cards.. this one was a feedback process until we came up with one with no extra storage.
What is use of #include in c?
What are the types of data structures in c?
What is const volatile variable in c?
Explain the use of keyword 'register' with respect to variables.
How do you sort filenames in a directory?
What are void pointers in c?
What is gets() function?
can anyone please tell about the nested interrupts?
What does main () mean in c?
What is data types?
Explain the use of 'auto' keyword