Give a big theta estimate for the number of operations Where

Give a big- (theta) estimate for the number of operations (Where an operation is an addition or a multiplication) used in this segment of an algorithm: (Your answer must be in terms of n)

a) t:= 1

for i= n to n2

t:= t+2t

Solution

T=1. Executes once
Loop executes n^2-n times
T=t+2t executes until the loop executes I.e.,n^2-n.

Total time:
n^2-n+n^2-n+1
= 2n^2-2n+1
Complexity : theta(n^2)

Give a big- (theta) estimate for the number of operations (Where an operation is an addition or a multiplication) used in this segment of an algorithm: (Your an

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site