A strange function. Consider McCarthys 91 function: public static int mcCarthy(int n) { if (n > 100)
Question:
A strange function. Consider McCarthy’s 91 function:
public static int mcCarthy(int n)
{
if (n > 100) return n - 10;
return mcCarthy(mcCarthy(n+11));
}
Determine the value of mcCarthy(50) without using a computer. Give the number of recursive calls used by mcCarthy() to compute this result. Prove that the base case is reached for all positive integers n or find a value of n for which this function goes into an infinite recursive loop.
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Related Book For
Introduction To Programming In Java An Interdisciplinary Approach
ISBN: 9780672337840
2nd Edition
Authors: Robert Sedgewick, Kevin Wayne
Question Posted: