Prices are given in t he array p n leftarrow length p if n

Prices are given in t he array p n leftarrow length (p) if n = 1 then return \"No way to make money.\" buy leftarrow 1 sell leftarrow 2 if p[1] (p[sell] - p[buy]) then sell leftarrow k buy leftarrow minsofar if p[k]

Solution

Answer:

The asymptotic time complexity of this code will be O(n) appearantly.

Let we look at the given code , we are having only one simple loop means n minus 3 operations therefor n -3 is equivalent to n so it\'s a big oh of n : O(n)

 Prices are given in t he array p n leftarrow length (p) if n = 1 then return \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site