资源描述:
《solution_of_algorithm(1) 》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、{nSKëYnµÅï#µÇnJason−xjx@sjtu.edu.cnUkاkÉÆ·éX,"1chap1{©ÛÄVg1.5a)ê
2、U,Sü§MODSELECTIONSORT1Dgê§0"b)ê
3、UüSü§MODSELECTIONSORT1Dgêõ§3n(n-1)/2"1.9Ò'gêó§INSERTIONSORTk"ÒDgêó§SECLECTIONSORTk"üömE,5þO(n2)"XJÑê
4、dþ
5、¤§Ì'üöDgê§w,SECLECTIONSORTk"1
6、.13FTFTTTFwww.khdaw.comTFTFFFTF1.16(a)ê
7、U,Sü§'gê§n-1g"(b)ê
8、UüSü§'gêõ§n(n-1)/2g"(c)ê
9、U,Sü§Dgê§0g"(d)ê
10、UüSü§Dgêõ§3n(n-1)/2g"(e)O(n2),Ω(n).(f)Ã{^ΘL«"ØÎܽÂ"1.17f(n)=课后答案网nn+sinn,g(n)=nn+cosn1.25O(1)±L«~ê½$¶Θ(1)UL«~ê"1.31(a)16Ú1blognc(blognc+1)
11、(2blognc+1).(b)^ΘL«Ü·"ÏO(blog3nc)=Ω(blog3nc)(c)mE,5´Θ(blog3nc)1.32(a)n2§16Úgê´nlogn(b)????n3§16Úgê´nblognc(c)O(nlogn)(d)Ω(n)(e)^OL«Ü·"âΘ½Â§T{Ø3°(mE,Ý"11.33(a)????n2§17Úgê´n(n+1)blog3cn/2(b)n3§16Úgê´n(n+1)log3n/2(c)O(n2log3n)(d)Ω(n2)(e)^OL«Ü·"âΘ
12、½Â§T{Ø3°(mE,Ý"1.37ê
13、A[0,1,2...n]L«a0,a1...an(a)Ω(n2).sum←A[0]fori←1tontemp←1forj←1toitemp←temp*xj←j+1endforsum←sum+A[i]*tempi←i+1endforreturnsum(b)O(n).sum←0www.khdaw.comfori←nto0sum←sum*x+A[i]i←i-1endforreturnsum2chap2êÆý£2.101){课后答案网µk=blognc,Kblognc≤l
14、ognblognc+1,=2k≤n<2k+1,Ké?¿ên,k2k15、§zHdΘ(n),omdΘ(kn)=Θ(nlogn).(b)Ó(a)©Û§mdΘ(2nlogn)=Θ(nlogn).(c)Ó(a)©Û§mdΘ(n2log2)=Θ(n2).5.12©ÛüSmd§Xi×B[i](i=1,2,...,k)¥êÅCþ"é×B[i]¥?1üS§Ï"mE[O(Xi2)]=O[E(Xi2)].duzá×B[i]VÇ1/k,zá×¥¯pÕá"ÅCþXÑl©ÙB(n,p).E(Xi)=np=n/k,V(Xi)=np(1−p)=(k−1)n/k2.
16、E(Xi2)=V(Xi)+E2(Xi)=(n2+(k−1)n)/k2"o$1mk×(n2+(k−1)n)/k2=(n2+(k−1)n)/k.§ek©Cn§{mE,ÝΘ(n).5.14bcdf½{"www.khdaw.com5.33{XeµÑµn®üSê
17、A[1...n]ÚêxѵeA¥3üê§ÙÚTдx§K£ý¶ÄK£b"1.returnsumX(1,n)L§µsumX(s,t)1.ifs=tors>t2.returnfalse;课后答案网3.elseifA[s]+A[t]=x4.return
18、true;5.elseifA[s]+A[t]>x6.returnsumX(s,t-1);7.elsereturnsumX(s+1,t);4Chap6©£{6.52{ëÏ饣1k¤E"6.53^~`²£4º:Òok¤"/GÊÏ)¤ä"36.54n=2k,k>0.òn×nÚ©42k−1×2k−1fÚ§Kí"7u4fÚ§Ù{nÃí""^L.^¬CXùnÃí"Ú(Ü?§ù§3fÚ