ADA算法知识(一)

a) Consider the following statements. Which ones are true?

(i) If f(n) = nlogn, g(n)=(logn)^2+n , then g(n) is Omega(f(n)).

(ii) If f(n) = 1.3^n, g(n) = 30n^5+200n^3, then f(n) is O(g(n)).

(iii) If f(n) = n^2log _{5}n,g(n) = nlog(n) + 3n^2\log_{2}(n+2), then f(n) is \theta(g(n))

 

At first, (logn)^2<n , it is obviously , so g(n) time complexity is O(n),and f(n) time complexity is O(nlogn), so O(n)<O(nlogn), so f(n)>g(n),so g(n) is O(f(n)), but the first statement shows that g(n) is Omega(f(n)) ,which is wrong, so the first question is false.

Second, it is obviously that f(n)>g(n), so g(n) is O(f(n)) , f(n) is Omega(g(n)), so the second question is false too.

Third , it is obviously that f(n) is \theta(g(n)) , it is true

如果光是要记住如何做题的话,只需要记住当g(n)<=f(n)的时候,g(n)=O(f(n))

b)Compute gcd(92142,21618) using Euclid's algorithm. Show all working.

(92142,21618)

92142/21618 = 4 ······ 5670

21618/5670 =  3 ······ 4608

5670/4608 = 1 ······ 1062

4608/1062 = 4 ······ 360

1062/360 = 2 ······ 342 

360/342 = 1 ······ 18

342/18 = 19

so 18 is the euclid , we get the result

 

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值