GATE / CS ARCHIVE

GATE CSE 1998 / QUESTION 2.12

Nested recursion yielding91

Compiler Design · Other / Mixed Topics · Full GATE CSE 1998 paper

GATE 1998, Q2.12 2 marks · MCQ
Report issue

Other / Mixed Topics

Question 2.12, GATE 1998: F(x)=x−10 for x>100, otherwise F(F(x+11)). Evaluate F(95) among 89, 90, 91, 92.
Question 2.12, GATE 1998: F(x)=x−10 for x>100, otherwise F(F(x+11)). Evaluate F(95) among 89, 90, 91, 92.
Tap to enlarge
Your answer
Answer & solution

Answer: C: 91 (no official key was published)

Step through it (21 steps)

First F(100)=F(F(111))=F(101)=91. For x from 95 through 99, x+11 exceeds 100, so F(x+11)=x+1. Hence F(x)=F(x+1) for these five inputs. Chaining gives F(95)=F(96)=…=F(100)=91. Thus C. This local calculation proves the requested value without assuming the more general McCarthy 91 theorem for every input.

Original paper, page 4