Question: Find how many times the string test will be printed in each of the following code fragments. Show all the details of calculations; your answer

  1. Find how many times the string test will be printed in each of the following code fragments. Show all the details of calculations; your answer must be a function of n.

(a)

i=0

while i < 2n

print test

i = i+2

(b)

i=0

while i < n

for j = 0 to n

print test

i = i+1

(c)

for i = 0 to n

for j = 0 to i

print test

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 Databases Questions!