2016华南理工大学数据结构试卷A及答案_第1页
2016华南理工大学数据结构试卷A及答案_第2页
2016华南理工大学数据结构试卷A及答案_第3页
2016华南理工大学数据结构试卷A及答案_第4页
免费预览已结束,剩余1页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

«Da«DataStructure?A试卷题号一二三四五六七八九十一总分得分评卷人考前须知:1.考前请将密封线内填写清楚;2.所有答案请直接答在试卷上;3.测试形式:闭卷;4.本试卷共十大题,总分值100分,测试时间120分钟.1.Selectthecorrectchoice.(20scores,each2scores)诚信应考,测试作弊将带来严重后果!华南理工大学期末测试⑴AnalgorithmmustbeordoallofthefollowingEXCEPT:(B)(A)Partiallycorrect(B)Ambiguous(C)terminate(D)ConcretestepsPickthegrowthratethatcorrespondstothemostefficientgrowingalgorithmasngetslarger:(B)(A)4n3(B)5n2logn(C)3n!(D)2nIfadataelementrequires12bytesandapointerrequires4bytes,thenalinkedlistrepresentationwillbemorespaceefficientthanastandardarrayrepresentationwhenthefractionofnon-nullelementsislessthanabout:(B)(A)1/3(B)3/4(C)3/5(D)2/3Whichistherealizationofadatatypeasasoftwarecomponent:(A)(A)Anabstractdatatype(B)Arealdatatype(C)Atype(D)AdatastructureThemosteffectivewaytoreducethetimerequiredbyadisk-basedprogramisto:(B)(A)ImprovethebasicI/Ooperations.(B)Minimizethenumberofdiskaccesses.(C)Eliminatetherecursivecalls.(D)Reducemainmemoryuse.Inthehashfunction,collisionrefersto(B).Twoelementshavethesamekeyvalue.Differentkeysaremappedtothesamepositionofhashtable.Tworecordshavethesamerequiringnumber.Dataelementsaretoomuch.GivenanarrayasA[m][n].SupposedthatA[0][0]islocatedat644(io)andA[4][4]isstoredat676i.).(彳0)“meansthatthenumberispresentedindecimals.ThentheelementA[2][2](io)isatposition:(B)(A)692(B)660(C)650(D)708Whichstatementisnotcorrectamongthefollowingfour:(A)Thenumberofemptysub-treesinanon-emptybinarytreeisonelessthanthenumberofnodesinthetree.TheMergesortisastablesortingalgorithm.Therootofabinarytreetransferredfromageneraltreehasonlyleftchild.Asectoristhesmallestunitofallocationforarecord,soallrecordsoccupyamultipleofthesectorsize.(9)Treeindexingmethodsaremeanttoovercomewhatdeficiencyinhashing?(D)(A)Inabilitytohandlerangequeries.(B)Inabilitytomaximumqueries(C)Inabilitytohandlequeriesinkeyorder(D)Allofabove.(10)Assumethatwehaveeightrecords,withkeyvaluesAtoH,andthattheyareinitiallyplacedinalphabeticalorder.Now,considertheresultofapplyingthefollowingaccesspattern:FDFGEGFADFGEifthelistisorganizedbythetransposeheuristic,thenthefinallistwillbe(B).(A)AFCDHGEB(B)ABFDGECH(C)ABFGDCEH(D)AHFDGECBFilltheblankwithcorrectC++codes:(16scores)Givenanarraystoringintegersorderedbyvalue,modifythebinarysearchroutinestoreturnthepositionofthefirstintegerwiththeleastvaluegreaterthanKwhenKitselfdoesnotappearinthearray.ReturnERRORifthegreatestvalueinthearrayislessthanK:(10scores)//Returnpositionoflestelement>=Kintnewbinary(intarray[],intn,intK){intl=-1;intr=n;//landrbeyondarrayboundswhile(l+1!=r){//Stopwhenlandrmeet_inti=(l+r)/2一;//Checkmiddleofremainingsubarrayif(K<array[i])r=i;//Inlefthalfif(K==array[i])returni;//Founditif(K>array[i])l=i//Inrighthalf}——//KisnotinarrayorthegreatestvalueislessthanKifK<array[n-1]orr!=nthenreturnr;//thefirstintegerwiththeleastvaluegreaterthanK//whenKitselfdoesnotappearinthearrayelsereturnERROR;//thegreatestvalueinthearrayislessthanK}⑵Theheightoftheshortesttreeandthetallesttreewithbothnnodesisrespectively

_2_orn(n<2)and__n_,supposethattheheightoftheone-nodetreeis1.A3-aryfulltreewithninternalnodeshas__3n+1_nodes.(6scores)Pleasecalculatethenumberofbinarytreesindifferentshapewith6nodesintotal,and6nodes?(4scores)2nodes:2shapes3nodes:rootwith1and2canbeallocatedtoleftandrightso1+2+2=54nodes:3canbeallocatedas0,3;1,2;2so5+5+2+2=145nodes:14+14+5+5+4=426nodes:32+32+14+14+5*2*2=132,C2nn/n+1AcertainbinarytreehasthepostorderenumerationasDCBEHJIGFAandtheinorderenumerationasBCDAEFGHIJ.Trytodrawthebinarytreeandgivethepostorderenumeration.(Theprocessofyoursolutionisrequired!!!)(6scores)preorderenumeration:ABCDFEGIHJ5.Designanalgorithmtotransferthescorereportfrom100-pointto5-point,thelevelEcorrespondingscore<60,6cH69beingD,70〜79beingC,80〜89asB,score>=90asA.Thedistributiontableisasfollowing.Pleasedescribeyouralgorithmusingadecisiontreeandgivethetotalpathlength.(6scores)Scorein100-point0-5960-6970-7980-8990-100Distributionrate5%10%45%35%5%solution:thedesignlogicistobuildaHuffmantreeTotallength:4*10%+10%*3+35%*2+45%=1.85,the0-false,1-trueasthelogicbranches.Recoveryageneraltreeasfollowingtransferredfromabinarytree.(4scores)TracebyhandtheexecutionofQuicksortalgorithmonthearray:inta[]={44,77,55,99,66,33,22,88,79}Thepivotis66inthefirstpass,thesecondis55and88,thethirdis33and77,thefouris22,andsoontillthealgorithmisfinished.(6scores)initial:44,77,55,99,66,33,22,88,79pass1:442255336699778879TOC\o"1-5"\h\zpass2:442233556679778899pass3:332244556677798899pass4:223344556677798899finalsortedarray:223344556677798899(a)Describesimplythemaintasksofthetwophasesofexternalsorting.(4scoresThetaskoffirstphaseistobreakthefilesintolargeinitialrunsbyreplacementselection;thesecondphaseistomergetherunstogethertoformasinglesortedrunfile.(b)Assumethatworkingmemoryis512KBbrokenintoblocksof4096bytes(thereisalsoadditionalspaceavailableforI/Obuffers,programvariables,etc.)Whatistheexpectedsizeforthelargestfilethatcanbemergedusingreplacementselectionfollowedbytwopassesofmulti-waymerge?Explainhowyougotyouranswer.(4scores)Sinceworkingmemoryis512KBandtheblocksizeis4KB,theworkingmemoryholds128blocks.Theexpectedrunlengthis1024KB,soasinglepassofmultiwaymergeformsrunsoflength1024KB*128=128MB.Thesecondpassthenformsarunaslargeas128MB*128=16GB.Assumeadiskdriveisconfiguredasfollows.Thetotalstorageisapproximately675Mdividedamong15surfaces.Eachsurfacehas612tracks;thereare144sectors/track,512byte/sector,and16sectors/cluster.Thediskturnsat7200rmp(8.33ms/r).Thetrack-to-trackseektimeis20ms,andtheaverageseektimeis80ms.Nowhowlongdoesittaketoreadallofthedataina380KBfileonthedisk?Assumethatthefile'sclustersarespreadrandomlyacrossthedisk.AseekmustbeperformedeachtimetheI/Oreadermovestoanewtrack.Showyourcalculations.(Theprocessofyoursolutionisrequired!!!)(6cores)Aclusterholds16*0.5K=8K.Thus,thefilerequires380/8=47.5clusters.Thetimetoreadaclusterisseektimetothecluster+latencytime+(interleaffactorxrotation

time).Averageseektimeisdefinedtobe80ms.Latencytimeis0.5*8.33,andclusterrotationtimeis47.5*(16/144)*8.33.Seektimeforthetotalfilereadtimeis47*(80+0.5*600/72+(16/144)*600/72)+(80+0.5*600/72+(8/144*600/72))=4083.98msUsingclosedhashing,withdoublehashingtoresolvecollisions,insertthefollowingkeysintoahashtableofelevenslots(theslotsarenumbered0through10).ThehashfunctionstobeusedareH1andH2,definedb

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论