Question: Show the o notation for the folowing code fragments a. for x = 1 or n/2 for y=1 to n a = a+1 b. for

Show the o notation for the folowing code fragments

a.

for x = 1 or n/2

for y=1 to n

a = a+1

b.

for x=1 to n

{

y=1

while y < n

y=y+y

c.

for x=1 to n

y=y+1

for d=1 to n

for e=1 to n

z=z+1

** What is O notation for parts a through c? (if it was all on one program)

**For the following code, specifiy the O notation for each step, and the total O notation for the whole segment

for a=1 to n

for b=5 to n

for c=1 to n

x= x+1

total = ?

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!