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
How can you draw circles in C?
Was 2000 a leap year?
Write a factorial program using C.
What is the use of pointers in C?
What are the types of data types and explain?
Is fortran still used in 2018?
shorting algorithmS
write a program to print data of 5 five students with structures?
show how link list can be used to repersent the following polynomial i) 5x+2
How can you call a function, given its name as a string?
When should structures be passed by values or by references?
Why we write conio h in c?
What is the advantage of a random access file?
What is main return c?
Explain what are the different data types in c?