計(jì)算機(jī)組成原理_第1頁
計(jì)算機(jī)組成原理_第2頁
免費(fèi)預(yù)覽已結(jié)束,剩余1頁可下載查看

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

ISingleChoice(10 )Forthefollowingprogramfragmenttherunningtime(Big-Oh)is i=0;s=while(s<(5*n*n+ s=s+}a. b. c. d. )Whichisnon-lineardata a. c. d.sequence )Theworst-timeforremovinganelementfromasequence (Big-Oh) a. b. c. d. )Inacircularqueuewecandistinguish(區(qū)分)emptyqueuesfromfullqueues usingagapintheincrementingqueuepositionsby2insteadof1c.keeacountofthenumberofelementsd.aand )Arecursivefunctioncancauseaninfinitesequenceoffunctioncalls theproblemsizeishalvedateachtheterminationconditionisnousefulincrementalcomputationisdoneineachtheproblemsizeis )Thefullbinarytreewithheight4 a. b. )Searchinginanunsortedlistcanbemadefasterby binaryasentinel(哨兵)attheendofthelinkedlisttostoretheaand )Supposethereare3edgesinanundirectedgraphG, IfwerepresentgraphGwithaadjacencymatrix,Howmany“1”sarethereinthematrix?a. b. c. d. )ConstructaHuffmantreebyfourleafwhoseweightsare9,2,5,7respectively.Theweightedpathlengthis a. b. c. ConsiderthefollowingweightedConsiderDijkstra’salgorithmonthisgraphtofindtheshortestpathswithsasastartingvertex.Whicharethefirstfourverticesextractedfromthepriorityqueuebythealgorithm(listedintheordertheyareextracted)?a.s,y,t, b.s,y,x, c.s,t,y, d.s,y,x,Fig.Hereisanarrayoftenintegers:5389170264Supposewepartitionthisarrayusingquicksort'spartitionfunctionandusing5forthepivot.Whichshowsthearrayafterpartitionfinishes:534210796034215796310245896310245897NoneoftheFillinBlank(10Forthefollowingprogramfragmenttherunningtime(Big-Oh)is for(inti=0;i<n;i++)for(intj=0;j<=i; //sWestorea4×4symmetricmatrixAintoanarrayBwithrowmajororder,Storethelowertriangleonly.theindexofelementa[2][3]inBis Wecanuse3vectortypetostorevalueand ofnon-zeroelementsinasparsematrix. isalistwhereremovalandadditionoccuratthesameend.FrequentlyknownaLIFO(Last-In-First-Out)structure.T(n)=2T(n/2)+ T(n)=T(n- T(n)= Thereisabinarytreewhoseelementsarecharacters.Preorderlistofthebinarytreeis“ABECDFGHIJ”andinorderlistofthebinarytreeis“EBCDAFHIGJ”.Postordertraversalsequenceofthebinarytreeis There leafnodesinafullbinarytreewithn8.Whentheinputhasbeensorted,therunningtimeofinsertionsort(Big-Oh) 9.Wesortthesequence(43,02,80,48,26,57,15,73,21,24,66)withssortincrement3,theresultis _sizeis“maxsize”.Wheninsertanelementinthequeue,rear= 11.A isanexampleofasearchtreewhichismultiway(allowsmorethantwochildren).12.Atreeinwhicheverynodeisnosmallerthanitschildrenis ApplicationofAlgorithms(35GraphGshowninFig2isadirectedgraph,pleasedescribeGwithadjacencymatrixandwritetheordersofbreadthfirsttraversalanddepthfirsttraversal.BBCAEDThesequenceofinputkeysisshownbelow:Afixedtablesizeof19andahashfunctionH(key)=key%13,withlinearprobing(線性探測(cè)),fillthetablebelowandcomputetheaveragelengthofsuccessfulsearch.Showtheresultsofinserting53,17,78,09,45,65,87each,oneatatime,inainitiallyemptymaxwritethesequenceofpreorder,postordertraversalsandaddinorderthreadsintheAABCDEFFig.BuildaHuffmantreeand determineHuffmancodewhentheprobabilitydistribution(概率分布)overthe8alphabets(c1,c2,c3,c4,c5,c6,c7,c8)is(0.05,0.25,0.03,0.06,0.10,0.11,GraphGshowninFig4isadirectedgraph,pleasedescribeGwithadjacencylistandwritetopologicalordering.Fig.Fillinblankofalgorithms.1.HereissinglesourceshortestpathalgorithmDijkstraFillinblankofthealgorithm.classGraph{ floatfloatdist[NumVertices];//最短路徑長度數(shù)組intpath[NumVertices]; intS[NumVertices]; voidShortestPath(int, int);intchoose(int);voidGraph::ShortestPath(int intv//n個(gè)頂點(diǎn)的帶權(quán)有向圖中,Edge[i][j]給出。建立一個(gè)數(shù)組dist[j],0j<n,//vj的最短路徑長度,path[j],0j<n,for(inti=0;i<n;i++)dist[i] //distS[i]=if(i!=v&&dist[i]<MAXNUM)path[i]=v;elsepath[i]=-1; //path數(shù)組初始化}S[v] dist[v] //頂點(diǎn)v//選擇當(dāng)前不在集合S中具有最短路徑的頂點(diǎn)ufor(i=0;i< ;i++){floatmin=MAXNUM; intu=v;for(intj=0;j<n;j++)if(!S[j] {u= min=dist[j];S[u]=1; //將頂點(diǎn)u加入集合Sfor(intw=0;w<n;w++) if(!S[w]&&Edge[u][w]<MAXNUM {dist[w] path[w]= }(圓括號(hào))andnumbers.PleaseFillinblank.#include<stack>Usingnamespaceintmatching(string&exp)//expisapointertoastringtocheckintstate=1,i=0;chare;stack<char>s;while(i<exp.length()&&state)switch(exp[i]){case;case')':if ) i++;state=0; //anerroroccursi++; //endofif return returnProgrammingWriteefficientfunctions(andgivetheirBig-Ohrunningtimes)thattakeapointertoabinarytreerootTandcompute:–ThenumberofleavesofTtypedefstructBiTNode struct }BiTNode,WriteamethodcalledumDegreeofanundirectedhgraphthatreturnstheumdegreeofanyvertexinthegraph.Thegraphisstoredwithadjacencymatrix.Writethedefinitiono

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論