[This page is auto-generated; please prefer to read the article’s PDF Form.]
Whenever a recursive method like recur() calls itself, it results in executing the complete method or a part of it again. And this repetition can take place any number of times. But the new method recur_stack() can contain no such recursive function calls. So we will need to arrange for repeating the logic of method recur() or a part of it, while continuing to execute within recur_stack(). A while-loop can be used for this. We will keep one iteration for every time the method recur() is called afresh by its caller (here a virtual-call). Also, when a virtual-call returns, we need to resume execution of the earlier virtual-call which had made that call. We will use a new iteration to resume executing the call (there is nothing like “returning” to an earlier iteration).
Copyright © 2020 Nitin Verma. All rights reserved.