Prove or disprove the following: L > -’—‘_—:_1
FEn 2 g |
fn) =T +n
g(n) = 4n®
f(n) € O(g(n))
Use the Big-Oh definition and set appropriate parameters (do not use limits for this question).
, | —
Question 2: [6 marks]
Find the cost function of the following algorithm and express the upper bound of the time
complexity in asymptotic notation.
func (n) { | Yoln
hi=1 ~————> .
for (i=0;i <myi++4) { ~— 7 |
hi=hi*2} X =
while (hi
> 0) { —> & X
hi=hi—2} =
¥