How can we check whether an Oz function is tail-recursive?
by checking whether there are less than two recursive calls in the body of the recursive function; |
||
by checking whether it runs fast enough for some input data and does not have infinite calls; |
||
by converting to the kernel language and by checking whether the recursive call is the last expression in the body of the recursive function; |
||
by checking whether the recursive call is the last expression in the body of the recursive function; |
||
none of the above. |
Ans. Option : C
by converting to the kernel language and by checking whether the recursive call is the last expression in the body of the recursive function
Oz function is tail recursive and we can check the version by converting the function into kernel language and then by checking that whether this recursion function in the last step or last expression in the body of the recursion function.
That's why the function is known as tail recursive because tail recursive functions because recursive calls are the last step of overall expression and the last things that happened.
In such cases, an intelligent compiler removes the element from the stack immediately after a recursion call.
Get Answers For Free
Most questions answered within 1 hours.