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 / ashwini

struct node
{
int data;
struct node *ptr;
};


struct node mid_element(struct node* head)//since we pass addr
{
int count=0,n_count,i=0;
struct node* temp,*mid;
temp=mid=head;
while(temp -> ptr != NULL)
{
count++;
temp = temp->otr;
}
count++;

if(count % 2)
{
n_count = (count/2)+1;
for(i=0 ; i<n_count ; i++)
mid = mid -> ptr;
}

return mid;
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you mean by a sequential access file?

1089


What are header files in c?

1088


What is structure packing in c?

1088


What is FIFO?

1745


Explain what is dynamic data structure?

1175


Explain the difference between #include "..." And #include <...> In c?

1038


What is meant by high-order and low-order bytes?

1051


When should a far pointer be used?

1141


What is adt in c programming?

1174


What is typeof in c?

1018


How can you read a directory in a C program?

1152


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

1199


How will you declare an array of three function pointers where each function receives two ints and returns a float?

1380


When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd

1068


Why use int main instead of void main?

1127