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
What is a tree in c++?
what is data encapsulation in C++?
What is the use of c++ programming language in real life?
How do you declare A pointer to function which receives an int pointer and returns a float pointer
Difference between an inspector and a mutator
Explain this pointer?
Do the parentheses after the type name make a difference with new?
What are libraries in c++?
How do you instruct your compiler to print the contents of the intermediate file showing the effects of the preprocessor?
How do I start a c++ project?
Discuss the possibilities related to the termination of a program before entering the mainq method?
What is a null object in c++?
What problems might the following macro bring to the application?
What is abstraction with real time example?
Explain storage qualifiers in c++.