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
Explain the static storage classes in c++.
Give an example of run-time polymorphism/virtual functions.
What is null c++?
What is the best book for c++ beginners?
Write a program to add three numbers in C++ utilizing classes.
What do you mean by “this” pointer?
Where the memory to the static variables is allocated?
daily Routine of father
What is data structure in c++?
What is a class template in c++?
Differentiate between a constructor and a method in C++.
What is the use of 'this' pointer?
Why is c++ still best?
To which numbering system can the binary number 1101100100111100 be easily converted to?
What is static class data?