Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Why do some versions of toupper act strangely if given an upper-case letter?

1078


how logic is used

1973


How was c created?

1064


How can I copy just a portion of a string?

1318


Explain what is the benefit of using #define to declare a constant?

1194


What is array in c with example?

1270


Why is c called "mother" language?

1295


What are the preprocessor categories?

1065


What is difference between array and structure in c?

1193


What is c mainly used for?

1066


What is .obj file in c?

1087


What is character constants?

1187


What is the purpose of & in scanf?

1078


What will the preprocessor do for a program?

1077


What are the general description for loop statement and available loop types in c?

1129