![浙江大学2010–2011学年冬季学期《高级数据结构与算法分析》课程期末考试试卷_第1页](http://file4.renrendoc.com/view5/M00/06/2A/wKhkGGY8G7eAH5neAAGF-5h5xro705.jpg)
![浙江大学2010–2011学年冬季学期《高级数据结构与算法分析》课程期末考试试卷_第2页](http://file4.renrendoc.com/view5/M00/06/2A/wKhkGGY8G7eAH5neAAGF-5h5xro7052.jpg)
![浙江大学2010–2011学年冬季学期《高级数据结构与算法分析》课程期末考试试卷_第3页](http://file4.renrendoc.com/view5/M00/06/2A/wKhkGGY8G7eAH5neAAGF-5h5xro7053.jpg)
![浙江大学2010–2011学年冬季学期《高级数据结构与算法分析》课程期末考试试卷_第4页](http://file4.renrendoc.com/view5/M00/06/2A/wKhkGGY8G7eAH5neAAGF-5h5xro7054.jpg)
![浙江大学2010–2011学年冬季学期《高级数据结构与算法分析》课程期末考试试卷_第5页](http://file4.renrendoc.com/view5/M00/06/2A/wKhkGGY8G7eAH5neAAGF-5h5xro7055.jpg)
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
浙江大学2010–2011学年冬季学期《高级数据结构与算法分析》课程期末考试试卷课程号:__________,开课学院:软件学院、计算机学院、竺可桢学院考试试卷:√A卷、B卷(请在选定项上打√)考试形式:√闭、开卷(请在选定项上打√),允许带___无____入场考试日期:2011年1月18日,考试时间:120分钟诚信考试,沉着应考,杜绝违纪。考生姓名:学号:所属院系:_题序一二三四总分得分评卷人AnswerSheetPartI1.c2.b3.a4.c5.c6.d7.c8.a9.b10.cPartII1.H1->Element>H2->ElementH1->Left=H2H1->Npl=H1->Right->Npl+12.H->TheTrees[i]H->TheTrees[i]=CarryPartIIIhight=42.(1)(2)2.15(3)Nodifference.3,1,24,54:-3,1,24,54:-6,78,98:-6:-3,6,9(1)(3)3,6,9(2)3,23,21,54:-6,78,98:-6:-3,1,23,1,26,76:89,84.(1)readinstringsandparsetogetwords;Usestemmingandstopwordsfiltertoobtainterms;checkdictionarywitheachterm,ifit’snotin,insertitintodictionary;getpostinglistofthetermandinsertdocumentandpositions.(2)500*10MB=5GB;1,000,000,000*10KB=10TB.(3)Anymethodthatinvolvesdistributedcomputingisfine.5.(1)(2)a:011;b:0101;c:000;d:111;e:10;f:110;g:001;h:0100(3)e
g
a
f
a
d
ePartIVForeveryi{1,…,N}andb{1,…,B},letexits(i,b)isTrueifthereexistsasubsequenceofa1…aisumminguptoexactlyb,otherwiseisFalse.QUOTETrue,thereexistsasubsequenceofa1..aClearlyexists(1,b)=Trueifb=0orb=a1,andexists(1,b)=Falseforallotherb’s.Alsoexists(i+1,b)=exists(i,b)ORexists(i,b-ai+1)Wecancomputeallvaluesexits(i,b)inO(NB).Theanswertotheoriginalquestionisgivenbyexists(N,B).InPseudocode:X=<a1,a2,…an>Y=<1,2,3…B>EXIST[N+1,B+1]MAIN(X,Y): EXIST[0,0]=trueforjfrom1toB: doEXIST[0,j]=falseEXIST[1,j]=false EXIST[1,a1]=true forifrom2toN: forjfrom1toB: if(j-ai>0): EXIST[i,j]=EXIST[i-1,j]OREXIST[i,j-ai] Else EXIST[i,j]=EXIST[i-1,j] PrintEXIST(N,B)
NOTE:Pleasewriteyouranswersontheanswersheet.注意:请将答案填写在答题纸上。Pleasefillintheblanks(theanswerforeachblankisunique).(2pointseach)1.GivenAastherootofasubtreein
an
AVL-tree.Supposethatbeforeinsertion,thebalancefactors
of
leftchildandrightchildofAare-1
and0respectively.If
inserting
a
new
node
X
tothatsubtree
willmakethetreeunbalanced,whatkindofrotationshouldbetakento
keep
the
subtreebalanced?
a.
RR
rotation
b.
LL
rotation
c.
LR
rotation
d.
RL
rotation2.Given
a
12-node
splay
tree
with
keys
1,2,...,11,and12.What
willthesplaytree
look
like
after
Find(1),Find(2),…Find(11),andFind(12)?a.
a
complete
tree
of
12nodes
b.
a
tree
with
height
11c.
a
tree
with
height
6
d.
depends
on
the
initial
tree
structure3.WhichoneofthefollowingisNOTtrueaboutB+treesandAVLtrees:theyareboth--a.balancedbinarytrees b.fitforsequentialsearchesc.fitforrandomsearches d.fitforrangesearches4.For
a
skew
heap,
whichstatement
is
NOT
correct?
a.
Skew
heap
mayormaynotbea
leftist
heap
b.
The
right
path
of
a
skew
heap
can
be
arbitrarily
long
c.
Comparing
toleftistheaps,skew
heapsarealwaysmoreefficientinrunningtimeforeverymerge
d.
Comparing
to
leftist
heaps,skew
heaps
are
always
moreefficientinspace5.Todelete
the
minimum
key
from
a
binomial
queue
H,thereare4stepstogo:Step
1:
FindMin
in
Bk;
Step
2:
Remove
Bk
from
H
and
get
H’;
Step
3:
Remove
root
from
Bk
and
get
H”;
Step
4:
Merge
(H’,
H”).
Whichstep(s)willhavetotakeO(logN)time?a.only1 b.1and2 c.3and4 d.only46.Given3
itemsand
a
knapsack
with
capacity25.The
items
have
weights
20,15and10,and
profits23,18
and11,
respectively.The
percentagesoftheitemsthatshould
be
packed
to
obtain
maximum
profit
is
_______
a.
0,
100%,
100%
b.
100%,
33.33%,0
c.
100%,0,50%
d.
50%,
100%,
07.WhichoneofthefollowingstructureshasthepropertythatanyMconsecutiveinsertionsstartingfromemptyonetakeatmostO(MlogN)timeandasingleinsertiontakesatmostO(logN)time?a.Splaytree b.Skewheap c.Leftistheap d.BinomialQueue8.TosolveaproblemwithinputsizeNbydivideandconqueralgorithm,amongthefollowingmethods,istheworst.a.divideinto3sub-problemsofequalcomplexityN/2andconquerinO(N)b.divideinto3sub-problemsofequalcomplexityN/3andconquerinO(NlogN)c.divideinto2sub-problemsofequalcomplexityN/3andconquerinO(N)d.divideinto2sub-problemsofequalcomplexityN/3andconquerinO(NlogN)9.Theproblemof“Nqueens”istoplaceNqueensonanNNchessboardsuchthatnotwoqueensattack.If
the
problem
is
to
be
solved
by
backtrackingmethod,weneedtocheck_____edgesof
the
game
treewithN=3toseethatthereisnosolution.a.9 b.11 c.13 d.1510.WhichofthefollowingstatementsisNOTcorrect?a.UndirectedHamiltonCircuitandsatisfiabilityproblemareNP-complete.b.AlthoughanondeterministicTuringMachinecanalwayschoosethecorrectsteptosolveproblems,wecannotuseittosolveundecidableproblems.c.TheproblemofdeterminingwhetheragraphdoesnothaveaHamiltoniancycleisinNP-class.d.IfwecansolveanyNP-completeprobleminpolynomialtime,thenwewillbeabletosolve,inpolynomialtime,alltheproblemsinNP.Giventhefunctiondescriptionsofthefollowingtwo(pseudo-code)programs,pleasefillintheblanklines.(15points)1.ThefunctionistomergetwoleftistheapsH1andH2.(9points)PriorityQueueMerge(PriorityQueueH1,PriorityQueueH2){if(H1==NULL)returnH2;if(H2==NULL)returnH1;if() swap(H1,H2);//swapH1andH2 if(H1->Left==NULL) ②; else{ H1->Right=Merge(H1->Right,H2); if(H1->Left->Npl<H1->Right->Npl) SwapChildren(H1);//swaptheleftchildandrightchildofH1 =3\*GB3③; } returnH1;}2.ThefunctionistoinsertXintoabinomialqueueH.(6points)BinQueueInsert(ElementTypeX,BinQueueH){ BinTreeCarry; inti; H->CurrentSize++; Carry=malloc(sizeof(structBinNode)); Carry->Element=X; Carry->LeftChild=Carry->NextSibling=NULL; i=0; while(H->TheTrees[i]){ Carry=CombineTrees(Carry,①);//combinetwoequal-sizedtrees H->TheTrees[i++]=NULL; } ②; returnH;}Pleasewriteordrawyouranswersforthefollowingproblemsontheanswersheet.(50points)What
is
the
height
of
thehighest
AVL-tree
of
12nodes?(3points)Pleasedrawthe
highestAVL-treewithkeys
1,2,…,12,and
atthemeantime,keep
the
tree
as
aleftist-treeaswell.(5points)2.Given
the
keywords
and
searching
frequencies,
in
order
to
minimize
theexpectedtotal
accesstime,thereis
a
greedy
way
to
construct
the
binarysearch
tree:firstarrangeallthe
keywords
in
descendentorderoffrequencies;andtheninsert
thekeywordsin
thatorder
to
aninitially
emptyAVL-tree.
Giventhefollowingkeywordsandtheirfrequencies:keywordsbreakcasechardoreturnswitchvoidfrequencies22182052528Please:
(1)
show
the
AVL-tree
obtainedbytheabovegreedymethod;
and(5points)(2)give
the
totalsearch
cost
of
the
constructed
search
tree.(4points)3,1,24,54:66,9,8(3)ComparethisAVL-treewiththeoptimalbinarysearchtreeandtellthedifference.(3,1,24,54:66,9,83.Givena2-3treeasshowninthefigure.Please:(1)showtheresultofinserting7withsplittingstrategy;(2points)(2)showtheresultofdeleting4andthen5fromthetreeobtainedin(1);(2points)and(3)showtheresultofdeleting1,2,8andthen7fromthetreeobtainedin(2).(2points)4.(1)Pleasebrieflydescribetheprocessofbuildinganinvertedfileindex.(4points)(2)Given1billionfilesof10KBeach,andwith500milliondistinctterms.Supposethatthepostinglistofeachtermisalinkedlistwiththestructure:DocID(4bytes)TermPosition(2bytes)NextPointer(4bytes)Howmanybytesarerequiredtostoretheindex?Howaboutthefiles?(2points)(3)Ifyouonlyhavesomepersonalcomputerswith1GBmemoryand10GBharddisks,howwouldyouhandlethisindexingproblem?(4po
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 第一课珍惜新起点(人教版教案)
- 2023年项目经理工作计划
- 二三副船舶管理模拟考试试卷A
- 教科版高中物理选择性必修第一册第四章光及其应用6光的衍射与偏振7激光课件
- POCT项目可行性报告
- 重庆市大渡口区2022-2023学年五年级下学期期末英语试题
- 10.青山处处埋忠骨第二课时(教学设计)2023-2024学年统编版语文五年级下册
- 小程序游戏项目可行性报告
- 2024年山东省滨州市中考生物试题(含答案)
- 仓库配送人员实操考评方案
- 家长读书心得体会1000字高中(四篇)
- 医学伦理学-南京中医药大学中国大学mooc课后章节答案期末考试题库2023年
- 语言学概论-课件
- 2023年安徽省芜湖市小升初数学试卷(含答案)
- 神经外科昏迷诊疗指南2022版
- 土壤修复工程治理重难点分析及应对措施
- 内蒙古呼和浩特市新城区讨思浩小学2023年五年级数学第二学期期末综合测试试题含解析
- 2023届广东省深圳市龙岗区万科实验学校数学五年级第二学期期末调研模拟试题含解析
- 2022-2023学年湖北省襄阳市襄州区四年级数学第二学期期末联考试题含解析
- 京东店铺运营策划方案
- Module3 Unit2 The cows are drinking water.(说课稿)-2022-2023学年英语六年级下册
评论
0/150
提交评论