Question: for i = 1 to n { k = 1 while ( k < = n ) { print hello k = k * 2
for i to n
k
while k n
print hello
k k Careful!
a Show the look bracketing and the number of times each loop is executed.
b Give the expression Tn for the number of times hello is printed, in terms of n
c How many times will hello be printed if n if n if n Make sure its the correct answer you obtain if you substitute n by each of its values in the expression you have in b
d Give Tn in Theta notation, in its simplest form.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
