Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Cornerstones of Managerial Accounting

Authors: Mowen, Hansen, Heitger

3rd Edition

324660138, 978-0324660135

More Books

Students also viewed these Programming questions