Need a little help please... Which data structure would you most likely see in a
ID: 3698987 • Letter: N
Question
Need a little help please...
Which data structure would you most likely see in a non-recursive implementation of a recursive algorithm?
A typical implementation of recursion involves the use of a stack.” One of the times we may see a non-recursive implementation of a recursive algorithm would be using the RevPrint. This is accomplished by keeping “track of the pointer to each node until we reach the end of the list which is when the pointer that is traversing the list reached the end or NULL and then the data member would be printed into that last node, and the process would be repeated in revers until we reach the first element in the list.
Discuss how you might go about implementing this process and any other programming tools that might be needed to complete the implementation.
Explanation / Answer
Solution:
Which data structure would you most likely see in a non-recursive implementation of a recursive algorithm?
Discuss how you might go about implementing this process and any other programming tools that might be needed to complete the implementation.
In which case we can loop through the list till the last node is reached, that can be done by while loop.
for example:
while(node.next!= NULL)
{
node= node.next;
}
after the loop is terminated
the data member can be printed as
cout<<node.data;
I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.