• edited by
654 views
0 0 votes

What will be the output? for foo(4)

image:Q2_1.png

  1.   4332221234
  2.   4332221324
  3.  43222214
  4.   4332211223

1 Answer

2 2 votes

Answer is Option B

I have taken

foo() as f(), goo() as g() and printf() as pf() in my explanation.

Traverse Top-Down and Left to right. Wherever you've got pf(), print that number.

Position:
Show:

Related questions

4 4 votes
1 answers 1 answer
2.2k
2.2k views
admin asked Sep 15, 2015
2,150 views
I'm solving questions of recursion. But those problems are hard to debug in few minutes? Have you any such method that solve recursive problem in less time? I have writte...
0 0 votes
1 1 answer
794
794 views
firki lama asked Jan 8, 2017
794 views
We are given two strings: String 5 of length n and string $T$ of length m for the LC 5 problem, we have produced the following exponential time recursive program. LCM (...
1 1 vote
1 answers 1 answer
1.4k
1.4k views
shikharV asked Nov 15, 2015
1,373 views
The answer to the above problem is A but I am expecting it to be D as constant amount of work is required to solve each subproblem.27Define $A_{i j}^{(k)}=\min \left(A_{i...
2 2 votes
2 answers 2 answers
694
694 views
Rohan Mundhey asked Nov 6, 2016
694 views
Consider the following recursive functionint gun(int i){if(i>4)return(2+gun(i-5) + gun(i-2));return 1;}Find the value returned form the gun(15) ?