Search for question
Question

3.Consider the following pseudocode program:

program (int n)

if n == 1

return 0

else

return 1+program (floor (n/2))

(a) "Run" 4 the program on some inputs, to get a feel for how it operates. Eg: n = 32, -1.

(b) Prove that on input n € N₁ the output is [log₂ n].

(c) On input n € N₁,how many times is the line starting with return 1+ program (...executed?

Fig: 1