浙江大學(xué)2005–2006學(xué)年冬季學(xué)期《高級數(shù)據(jù)結(jié)構(gòu)與算法》課程期末考試試卷_第1頁
浙江大學(xué)2005–2006學(xué)年冬季學(xué)期《高級數(shù)據(jù)結(jié)構(gòu)與算法》課程期末考試試卷_第2頁
浙江大學(xué)2005–2006學(xué)年冬季學(xué)期《高級數(shù)據(jù)結(jié)構(gòu)與算法》課程期末考試試卷_第3頁
浙江大學(xué)2005–2006學(xué)年冬季學(xué)期《高級數(shù)據(jù)結(jié)構(gòu)與算法》課程期末考試試卷_第4頁
浙江大學(xué)2005–2006學(xué)年冬季學(xué)期《高級數(shù)據(jù)結(jié)構(gòu)與算法》課程期末考試試卷_第5頁
已閱讀5頁,還剩4頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

浙江大學(xué)2005–2006學(xué)年冬季學(xué)期《高級數(shù)據(jù)結(jié)構(gòu)與算法》課程期末考試試卷開課學(xué)院:軟件學(xué)院,考試形式:閉卷,允許帶__入場考試時間:_2005_年_1_月_10_日,所需時間:120分鐘考生姓名:___學(xué)號:專業(yè):____教師:題序一二三四總分得分評卷人NOTE:Pleasewriteyouranswersontheanswersheet.注意:請將答案填寫在答題紙上。Pleasefillintheblanks(Therecouldbemultipleanswersforoneblank).(30points)Note:Zeropointforablankselectionsincethereisatleastoneanswerforeachproblem.(1)ForanAVLtree,is(are)correct.(2points) a.Theheightofleftandrightsub-treesdiffersbyatmost1. b.TheinsertionoperationcanbeperformedinO(logN)time. c.AnAVLtreeisakindofbinarysearchtree. d.ThepurposeofusingAVLtreeistosavesomespace.(2)AnAVLtreeofheight6hastheminimumsizeofnodes.(2points) a.31 b.32 c.33 d.34(3)ForaB-tree,is(are)correct.(2points) a.AB-treeisnotasearchtree.b.Alltheleaveshavethesamedepth.c.Allnon-leafnodesofa2-3treehave1or3children.d.GenerallyaB-treeisnotabinarytree.(4)Foraleftistheap,is(are)NOTcorrect.(2points)a.Thetotalnumberofnodesintheleftsub-treeisalwaysnolessthanthatintherightsub-tree.b.AleftistheapofNnodeshasarightpathcontainingatmostlog(N+1)nodes.c.Comparingtobinaryheaps,leftistheapsaremoresuitabletodomerge.d.Abinaryheapisalsoaleftistheap.(5)Foraskewheap,is(are)NOTcorrect.(2points)a.Skewheapisakindofleftistheap.b.Therightpathofaskewheapcanbearbitrarilylong.c.Comparingtoleftistheaps,skewheapsarealwaysmoreefficientinrunningtimeforeverymerge.d.Comparingtoleftistheaps,skewheapsarealwaysmoreefficientinspace.(6)Amongthefollowingstatements,is(are)correct.(2points)a.TheamortizedtimeisanaveragetimeofNsuccessiveoperations.b.Theamortizedtimeistheworst-casetimeofNsuccessiveoperationsintotal.c.ThepotentialfunctionofNsuccessiveinsertionsofabinomialqueueisthenumberoftrees.d.Theamortizedtimecouldbemuchmorethantheactualtimeforoneoperation.(7)Forthefollowings,theO(logN)case(s)is(are),theO(N)case(s)is(are).(2points)a.Theworst-caserunningtimeofmergingtwoleftistheaps.b.Theworst-caserunningtimeofmergingtwoskewheaps.c.Theamortizedcostpermergeofaskewheap.d.BuildingaleftistheapfromNnumbers.(8)Forthefollowingproblems,is(are)undecidableproblem(s)andis(are)NP-completeproblem(s).(3points)a.Eulercircuitproblemb.Hamiltoniancycleproblemc.Satisfiabilityproblemd.Haltingprobleme.All-pairsshortestpathsproblemf.Binpackingproblem(9)Forthefollowingstatements,is(are)NOTcorrect.(2points)a.AllNPproblemsaredecidable.b.AllNP-completeproblemsareNPproblems.c.AlldecidableproblemsareNPproblems.d.AllNPproblemscanbesolvedinpolynomialtimeinanon-deterministicmachine.(10)Forabinomialqueuecontaining23nodes,pleasegivethenamesofnon-emptybinomialtreesinthisbinomialqueue(e.g.B0,B1,B3):.(5points)(11)Theturnpikereconstructionproblemistoreconstructapointsetfromdistancesbetweeneverypairofpoints.Givenasetofdistances{1,2,3,3,4,5,7,7,8,10},thecorrespondingpointsetcontainspointswithcoordinates.(6points)Giventhefunctiondescriptionsofthefollowingtwoprograms,pleasefillintheblanklinesofcode.(15points)(1)AsinglerotationbetweennodeK1anditsrightchildinanAVLtree.(9points)structAvlNode{ElementTypeElement;AvlTreeLeft;AvlTreeRight;intHeight;}TypedefstructAvlNode*Position;TypedefstructAvlNode*AvlTree;staticPositionSingleRotateWithRight(PositionK1){ PositionK2;;;;K1->Height=Max(Height(K1->Left),Height(K1->Right))+1;K2->Height=Max(Height(K2->Right),K1->Height)+1;returnK2;}(2)Findingtheoptimalorderingofmatrixmultiplications.(6points)voidOptMatrix(constlongr[],intN,TwoDimArrayM){inti,k,Left,Right;longThisM;for(Left=1;Left<=N;Left++)M[Left][Left]=0;for(k=1;k<N;k++)for(Left=1;Left<=N-k;Left++){Right=Left+k;M[Left][Right]=Infinity;for(L=Left;L<Right;L++){;if(ThisM<M[Left][Right]);}}}

Pleasewriteordrawyouranswersforthefollowingproblemsontheanswersheet.(40points)(1)Pleasedrawtheresultsofinserting{6,7,8,9,10,1,2,3,4,5}intoa.(6points)aninitiallyemptyAVLtree;andb.(7points)aninitiallyemptysplaytree.(Tip:Drawingthetreesstepbystepmighthelpyougettingpartialcredits.)33817182673718241233211410236(2)Pleasedrawtheresultofdeletingtheminimumnumberfromthegivenleftistheap.(5points)(3)Pleasedrawtheresultofmergingthegiventwobinomialqueues.(5points)132313235124651518211295512212465142616184H2:(4)Givenasegmentoftextthis_is_a_strange_string,howmanybitsarerequiredtostorethestringas1-bytecharacters?HowmanybitsareneededtostoreitsHuffmancode?PleasedrawtheHuffmantreewiththefollowingassumptions:a.Allthecharactersareinitiallystoredinanarrayinthealphabeticalorder;andb.Alltheleftbranchesarecodedwith0’sandalltherightbranchesarecodedwith1’s.(10points)(5)Pleaseshowtheoptimalbinarysearchtreeforthefollowingwords,wherethefrequencyofoccurrenceisinparentheses:an(0.10),be(0.20),can(0.30),if(0.25),or(0.15).(7points)GiventheadjacencymatrixGofaweightedgraph,withG[k][k]presumedtobe0.PleasewriteanalgorithmwithtimecomplexityO(N3)forprintingtheshortestpathsbetweenanytwoverticesI,andjforall0I<j<N.Thatis,youroutputmusthavetheformatasthefollowing:(15points)0->…->1……0->…->N–11->…->2……1->…->N–1……N–2->…->

溫馨提示

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

評論

0/150

提交評論