版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
浙江大学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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年浙江省东阳市《行测》考试考前冲刺密卷附完整答案详解(名校卷)
- 2026年黑龙江省同江市《行测》考试备考题库含完整答案详解【夺冠系列】
- 2025年湖北省仙桃市《行测》考试备考题库附完整答案详解(典优)
- 2025年湖北省潜江市《行测》考试模拟试卷附完整答案详解【各地真题】
- 2026年广东省南雄市《行测》考试模拟试卷含答案详解(满分必刷)
- 2026年广东省鹤山市《行测》考试模拟试卷附答案详解
- 2025年河北省黄骅市《行测》考试模拟试卷完美版附答案详解
- 2025年江西省樟树市《行测》考试考前冲刺试卷含完整答案详解(各地真题)
- ZINC69391-Standard-生命科学试剂-MCE
- 断桥铝门窗施工组织设计
- 《展望物联网》+课件+2025-2026学年川教版(2024)初中信息科技八年级上册
- 功能科考试题及答案
- 废气处理系统建设汇报报告
- DB61∕T 1802-2023 水工隧洞突涌水风险评估及防治技术规范
- 2023年8月19日广西区三支一扶面试真题及答案解析
- 2025年中国维生素D2行业市场发展前景及发展趋势与投资战略研究报告
- DB50∕T 548.1-2024 城市道路交通管理设施设置规范 第1部分:道路交通标志
- DZ/T 0275.3-2015岩矿鉴定技术规范第3部分:矿石光片制样
- 医疗机构中医护理门诊建设规范
- 富滇银行笔试题库及答案
- 药品记录与数据管理要求试行解读
评论
0/150
提交评论