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
What are the types of assignment statements?
Why void is used in c?
What header files do I need in order to define the standard library functions I use?
‘SAVEPOINT’ and ‘ROLLBACK’ is used in oracle database to secure the data comment. Give suitable examples of each with sql command.
difference between native and cross compilers
the portion of a computer program within which the definition of the variable remains unchanged a) mode b) module c) scope d) none
c program to compute AREA under integral
What are reserved words with a programming language?
Is there a built-in function in C that can be used for sorting data?
Who developed c language and when?
#include main() { int *p, *c, i; i = 5; p = (int*) (malloc(sizeof(i))); printf(" %d",*p); *p = 10; printf(" %d %d",i,*p); c = (int*) calloc(2); printf(" %d ",*c); }
What is the purpose of type declarations?
What are types of functions?
Can include files be nested?
What is calloc malloc realloc in c?