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 / mayank pathak

Maintain a queue with ten elements. As u encounter a new
element in the linked list dequeue one element and enqueue
this new element. When the link list is fully scanned the
first element of the queue would be the 10th last element.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the difference between class and struct in c++?

590


Why is c++ awesome?

580


Why ctype h is used in c++?

527


In a function declaration what does extern means?

603


Why do we need function?

604






What is a modifier in c++?

634


Is map ordered c++?

596


Why is main function important?

587


Who discovered c++?

563


Why should we use null or zero in a program?

606


Explain about templates of C++.

680


What do you mean by storage classes?

799


What is c++ good for?

589


Why is polymorphism useful?

569


Write a function to find the nth item from the end of a linked list in a single pass.

571