in Algorithms
198 views
0 votes
0 votes
 

Consider the code below, How many times the function Anand(2,3,3) is executed______?

 

The answer  is given as 65536.

Please provide solution for above question ?

in Algorithms
198 views

2 Comments

can you provide the solution?
0
0

Shaik here is the solution,

Solution :  

→ Evaluating Anand(m,n,3) for small values of n suggests that Anand(m,n,3)=mn.

→ Anand(m,0,3)=1= m0.

→ Assuming that Anand(m,n-1,3)=mn-1

→ Anand(m,n,3) = Anand(m,Anand(m,n-1,3),2) = Anand(m,mn-1,2) = m*mn-1 =mn

→ Anand(2,0,3) = 2.

    Anand(2,1,3) = Anand(2,Anand(2,0,3),2) = Anand(2,2,2) = 22 = 4.

    Anand(2,2,3) = Anand(2,Anand(2,1,3),2) = Anand(2,4,2) = 24 = 16.

    Anand(2,3,3) = Anand(2,Anand(2,2,3),2) = Anand(2,16,2) = 216 = 65536.

 

I didn't understood the solution.

0
0

Please log in or register to answer this question.