




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
浙江大學2005–2006學年冬季學期《高級數據結構與算法》課程期末考試試卷開課學院:軟件學院,考試形式:閉卷,允許帶__入場考試時間:_2005_年_1_月_10_日,所需時間:120分鐘考生姓名:___學號:專業:____教師:題序一二三四總分得分評卷人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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 小型工程器械管理制度
- 華為引入項目管理制度
- 華為公司運營管理制度
- 公司優化財務管理制度
- 國企銷售人員管理制度
- 醫藥公司辦公管理制度
- 工務段機具庫管理制度
- 品牌公司倉庫管理制度
- 工位器具倉庫管理制度
- 車展規劃方案(3篇)
- 中國稅制-稅收與百姓生活智慧樹知到期末考試答案章節答案2024年云南師范大學
- 無人機足球團體對抗賽項目競賽規則
- 《建筑材料》教案
- DB3502-Z 5043-2018 浮筑樓板應用技術規程
- 娃哈哈事件看公司治理-案例分析
- 成都市新津區招聘教師考試試題及答案
- AIAG-VDA-PFMEA表格模板(自動計算AP)
- 妊娠便秘疾病演示課件
- 種植體周圍炎的預防及治療
- 全口義齒工藝技術試題及答案
- 靜脈血液標本采集指南
評論
0/150
提交評論