Give the most compact theta notation for the number of time

Give the most compact theta notation for the number of time the stateme x = x + 1 is executed in the following pseudo-code: for i = 1 to i = 3n - 1{for j = 1 to j = n{x = x + 1

Solution

In the first Loop it runs for 3n-1 times.

In the Second case it runs n times.

Hence totally it runs (3n-1)*n

But as constants are not significant the value is Theta(n2)

 Give the most compact theta notation for the number of time the stateme x = x + 1 is executed in the following pseudo-code: for i = 1 to i = 3n - 1{for j = 1 t

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site