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 program to use switch statement.
Differentiate abs() function from fabs() function.
What is the equivalent code of the following statement in WHILE LOOP format?
Why c is a procedural language?
What is data types?
What are c preprocessors?
Explain can static variables be declared in a header file?
What is the use of extern in c?
7-Given an index k, return the kth row of the Pascal's triangle. For example, when k = 3, the row is [1,3,3,1]. For reference look at the following standard pascal’s triangle.
what is the height of tree if leaf node is at level 3. please explain
How can I remove the trailing spaces from a string?
When do we get logical errors?
Can you write the function prototype, definition and mention the other requirements.
what is the differnce between programing langauge and tool? is sas is a programing langauge r tool?
Why static is used in c?