Question: A strange function. Consider McCarthys 91 function: public static int mcCarthy(int n) { if (n > 100) return n - 10; return mcCarthy(mcCarthy(n+11)); } Determine

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.

Step by Step Solution

3.39 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The McCarthy 91 function is an interesting recursive function which eventually returns the value of ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Algorithm Design Questions!