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

Assume the list is a circular one (implemented by pos%10).
So, when you are iterating, you are going round and round in
a circle. When you reach the end, you just have to go back
exactly 10 items. By going back here means accessing the
element 10 position prior to the current one, which is
implemented by (pos-10)%10

Since, it's a circular array as assumed, you have always
access it by doing pos%10 or (pos-10)%10.

NOTE: The value of pos has always been incremented and never
decremented or set to zero.

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the uses of c++ in the real world?

993


If you hear the cpu fan is running and the monitor power is still on, but you did not see anything show up in the monitor screen. What would you do to find out what is going wrong?

1078


What are the advantages of early binding?

1025


Is there structure in c++?

984


Explain the volatile and mutable keywords.

1038


Write my own zero-argument manipulator that should work same as hex?

1007


Write a program using display() function which takes two arguments.

1022


How can I learn c++ easily?

1031


How would you use the functions sin(), pow(), sqrt()?

1145


What is pair in c++?

1013


What is a far pointer? where we use it?

1031


What is the difference between passing by reference and passing a reference?

1036


How can you specify a class in C++?

1234


What is the latest c++ version?

1065


What is the c++ code?

1097