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 is main () in c language?
Explain what are the __date__ and __time__ preprocessor commands?
Why do we use namespace feature?
while initialization of array why we use a[][2] why not a[2][]...?
Is a pointer a kind of array?
Explain null pointer.
using for loop sum 2 number of any 4 digit number in c language
What is the difference between functions abs() and fabs()?
What is the difference between text and binary modes?
Explain the use of keyword 'register' with respect to variables.
What is the code for 3 questions and answer check in VisualBasic.Net?
in any language the sound structure of that language depends on its a) character set, input/output function, its control structures b) character set, library functions, input/output functions its control structures c) character set, library functions, control sturctures d) character set, operators, its control structures
Was 2000 a leap year?
What is character set?
What is an lvalue?