MarkAllenWeiss数据结构与算法分析课后习题答案2339.pdf





《MarkAllenWeiss数据结构与算法分析课后习题答案2339.pdf》由会员分享,可在线阅读,更多相关《MarkAllenWeiss数据结构与算法分析课后习题答案2339.pdf(3页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、Chapter 2:Algorithm Analysis2.12/N,37,N,N,Nlog log N,Nlog N,Nlog(N2),Nlog2N,N1.5,N2,N2log N,N3,2N/2,2N.Nlog N and Nlog(N2)grow at the same rate.2.2(a)True.(b)False.A counterexampleis T1(N)=2N,T2(N)=N,and f(N)=N.(c)False.A counterexampleis T1(N)=N2,T2(N)=N,and f(N)=N2.(d)False.The same counterexample
2、as in part(c)applies.2.3We claim that Nlog N is the slower growing function.To see this,suppose otherwise.Then,N/log Nwould grow slower than log N.Taking logs of both sides,we find that,under this assumption,/log N log N grows slower than log log N.But the first expres-sion simplifies to log N.If L=
3、log N,then we are claiming that L grows slower thanlog L,or equivalently,that2Lgrowsslowerthanlog2 L.Butwe knowthatlog2 L=(L),so the original assumption is false,proving the claim.2.4Clearly,logk1N=(logk2N)if k1 k2,so we need to worry only about positive integers.The claim is clearly true for k=0 an
4、d k=1.Suppose it is true for k i.Then,byLHospitals rule,NlimNlogiN_ _=Nlim iNlogi1N_The second limit is zero by the inductive hypothesis,proving the claim.2.5Let f(N)=1 when N is even,and N when N is odd.Likewise,let g(N)=1 when N isodd,and N when N is even.Then the ratio f(N)/g(N)oscillates between
5、 0 and.2.6For all these programs,the following analysis will agree with a simulation:(I)The running time is O(N).(II)The running time is O(N2).(III)The running time is O(N3).(IV)The running time is O(N2).(V)j can be as large as i2,which could be as large as N2.k can be as large as j,which isN2.The r
6、unning time is thus proportional to N.N2.N2,which is O(N5).(VI)The if statement is executed at most N3times,by previous arguments,but it is trueonly O(N2)times(because it is true exactly i times for each i).Thus the innermost loop isonly executed O(N2)times.Each time through,it takes O(j2)=O(N2)time
7、,for a total ofO(N4).This is an example where multiplying loop sizes can occasionally give an overesti-mate.2.7(a)It should be clear that all algorithms generate only legal permutations.The first twoalgorithms have tests to guarantee no duplicates;the third algorithm works by shuffling anarray that
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- MarkAllenWeiss 数据结构 算法 分析 课后 习题 答案 2339

限制150内