Question: 3. (3 marks) Consider the following pseudocode program: program (int n) if n = 1 return 0 else return 1+program (floor (n/2)) (a) Run

3. (3 marks) Consider the following pseudocode program: program (int n) if

 

3. (3 marks) 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 [log2 n]. 5 (c) On input n N+, (roughly 6) how many times is the line starting with return 1 + program(... executed?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Programming Questions!