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 do you mean by a sequential access file?
What are header files in c?
What is structure packing in c?
What is FIFO?
Explain what is dynamic data structure?
Explain the difference between #include "..." And #include <...> In c?
What is meant by high-order and low-order bytes?
When should a far pointer be used?
What is adt in c programming?
What is typeof in c?
How can you read a directory in a C program?
Explain what is the benefit of using #define to declare a constant?
How will you declare an array of three function pointers where each function receives two ints and returns a float?
When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd
Why use int main instead of void main?