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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get StartedRecommended Textbook for
Cornerstones of Managerial Accounting
Authors: Mowen, Hansen, Heitger
3rd Edition
324660138, 978-0324660135
Students also viewed these Programming questions
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
View Answer in SolutionInn App