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...

Memory is not a constraint. In a single iteration(NOTE: you
can't go back), how will you find out the 10th last
node/item in a linked list.

Answer Posted / ashutosh

List *nodes[10]; //asked 10th last, so, only 10 items
int pos = 0;

List *ptr = &FirstNode

while(ptr)
{
nodes[(pos%10)] = ptr;
pos++;
ptr = ptr->next;
}
if(pos>=10)
{
printf("Tenth last element is %d",nodes[(pos-10)%10]->data);
}
else
{
printf("There doesn't exist any 1oth last element");
}

Is This Answer Correct ?    13 Yes 17 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is c++ w3school?

1056


What is the use of lambda in c++?

966


What is a NULL Macro? What is the difference between a NULL Pointer and a NULL Macro?

1049


Describe protected access specifiers?

1143


How can you say that a template is better than a base class?

1025


Is c++ low level?

992


Write about the stack unwinding?

1015


What is a string example?

1014


Explain how a pointer to function can be declared in C++?

978


Can constructor be static in c++?

1050


What is c++ and its features?

972


Explain virtual class and friend class.

994


Should I learn c++ c?

1000


What is the default access level?

1025


What do the keywords volatile and mean mutable?

1005