pgm to find middle element of linklist(in efficent manner)
Answer Posted / abdur rab
struct node {
int data;
struct node* next;
};
int mid_element ( struct node* _node )
{
struct node* cur_ptr;
struct node* cur_next_ptr;
if ( NULL == _node ) return ( -1 );
else {
cur_ptr = _node;
cur_next_ptr = _node;
while ( ( NULL != cur_ptr -> next )
&& ( NULL != cur_next_ptr -
> next )
&& ( NULL != cur_next_ptr -
> next -> next ) )
{
cur_ptr = cur_ptr -> next;
cur_next_ptr = cur_next_ptr ->
next -> next;
}
}
return ( cur_ptr -> data );
}
| Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
Why do some versions of toupper act strangely if given an upper-case letter?
how logic is used
How was c created?
How can I copy just a portion of a string?
Explain what is the benefit of using #define to declare a constant?
What is array in c with example?
Why is c called "mother" language?
What are the preprocessor categories?
What is difference between array and structure in c?
What is c mainly used for?
What is .obj file in c?
What is character constants?
What is the purpose of & in scanf?
What will the preprocessor do for a program?
What are the general description for loop statement and available loop types in c?