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
write a C program: To search a file any word which starts with ?a?. If the word following this ?a? starts with a vowel.Then replace this ?a? with ?a? with ?an?. redirect with the output onto an output file.The source file and destination file are specified by the user int the command line.
Why doesnt the call scanf work?
What is bubble sort technique in c?
What is volatile, register definition in C
What does struct node * mean?
Why c is a mother language?
What is a keyword?
Write a program to swap two numbers without using a temporary variable?
When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd
How will you write a code for accessing the length of an array without assigning it to another variable?
What are operators in c?
Are enumerations really portable?
GIVEN A FLOATING POINT NUMBER HOW IS IT ACTUALLY STORED IN MEMORY ? CAN ANYONE EXPLAIN?? THE 32 BIT REPRESENTATION OF A FLOATING POINT NUMBER ALLOTS: 1 BIT-SIGN 8 BITS-EXPONENT 23 BITS-MANTISSA
Is it possible to have a function as a parameter in another function?
what type of questions arrive in interview over c programming?