下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
1.FilltheblankwithcorrectC++codes:
Givenanarraystoringintegersorderedbydistinctvaluewithoutduplicate,modifythebinary
searchroutinestoreturnthepositionoftheintegerwiththesmallestvaluegreaterthanKwhenK
itselfdoesnotappearinthearray.ReturnERRORifthegreatestvalueinthearrayislessthanK:
(12scores)
//Returnpositionofsmallestclement>=K
intnewbinary(intarray[],intn,intK){
intl=-l;
intr=n;//1andrbeyondarraybounds
while(1+1!=r){//Stopwhen1andrmeet
___inti=(1+r)/2;//Lookatmiddleofsubarray
if(K<array[i])_r=i—;//Inlefthalf
if(K==array[i])_returni__;//Foundit
if(K>array[i])___l=i___//Inrighthalf
)
//KisnotinarrayorthegreatestvalueislessthanK
ifK<=array[n-lJ(orr!=n)_//thegreatestvalueinthearrayisnotlessthanKwithr
updated
returnr;//whenKitselfdoesnotappearinthearray
elsereturnERROR;//theintegerwiththegreatestvaluelessthanK
(2)Theheightofacompletebinarytreewithknodesis」log?(k+l)|[1nodetree
hashight1)
(3)Thenumberofdifferentshapesofbinarytreeswith5nodesis_42_.
2.AcertainbinarytreehasthepreorderenumerationasABECDFGHIJandthe
inorderenumerationasEBDCAFIHGJ.Trytodrawthebinarytreeandgivethe
postorderenumeration.(Theprocessofyoursolutionisrequired!!!)
3.Determine@forthefollowingcodefragmentsintheaveragecase.Assumethat
allvariablesareoftypeint.
(1)sum=0;
for(i=0;i<5;i++)
for(j=0;j<n;j++)
sum++;solution:?___(n)
(2)sum=0;
for(i=l;i<=n;i++)
for(j=n;j>=i;j-)
sum++;solution:?_(n2)
(3)sum=0;
if(EVEN(n))
for(i=0;i<n;i++)
sum++;
else
sum=sum+n;solution:?___(n)
4.Tracebyhandtheexecutionofcreationabinarysearchtreewiththeinputsequence
as:{46,25,78,62,12,37,70,29}whichisemptytreeinitially.
Solution:BSTobtainedwithdatainsertedonebyone
46
2578
123762
2970
5.Designanalgorithmtotransferthescorereportfrom100-pointto5-point,thelevel
Ecorrespondingscore<60,60?69beingD,70?79beingC,80?89asB,score>=90
asA.Thedistributiontableisasfollowing.Pleasedescribeyouralgorithmusinga
decisiontreeandgivethetotalpathlength.
Scorein100-point0-5960-6970-7980-8990-100
Distributionrate|5%10%45%25%15%
solution:
thedesignlogicistobuildaHuffmantree
Totallength:4+4+3+2+1=14,Averagelength:4*5%+10%*4+15%*3+25%*2+
45%=2.00,the0-false,1-trueasthelogicbranches.
6.Assumeadiskdriveisconfiguredasfollows.Thetotalstorageisapproximately
1.35Gdividedamong15surfaces.Eachsurfacehas612tracks;thereare144
sectors/track,1024byte/sector,and16sectors/cluster.Theinterleavingfactorisfour.
Thediskturnsat7200rmp(8.33ms/r).Thetrack-to-trackseektimeis20ms,andthe
averageseektimeis80ms.Nowhowlongdoesittaketoreadallofthedataina360
KBfileonthedisk?Assumethatthefile'sclustersarespreadrandomlyacrossthe
disk.AseekmustbeperformedeachtimetheI/Oreadermovestoanewtrack.Show
yourcalculations.(Theprocessofyoursolutionisrequired!!!)
Solution:
Thefirstquestionishowmanyclustersthefilerequires?
Aclusterholds16*1K=16K.Thus,thefilerequires360/16=22.5
clusters=22completeclusterand8k(8sectors)
Thetimetoreadaclusterisseektimetothe
cluster+latencytime+(interleaffactorXrotationtime).
Averageseektimeisdefinedtobe80ms.Latencytimeis0.5*8.33ms(60/7200q
8.33ms),andclusterrotationtimeis4*(16/144)*8.33.
Seektimeforthetotalfilereadtimeis
22*(80+0.5*8.33+4*(16/144)*8.33)+(80+0.5*8.33+4*(8/144)*8.33尸
2019.095ms
7.Usingclosedhashing,withdoublehashingtoresolvecollisions,insertthe
followingkeysintoahashtableofelevenslots(theslotsarenumbered0through10).
ThehashfunctionstobeusedareH1andH2,definedbelow.Youshouldshowthe
hashtableafteralleightkeyshavebeeninserted.Besuretoindicatehowyouare
usingHlandH2todothehashing.(Theprocessofyoursolutionisrequired!!!)
Hl(k)=3kmod11H2(k)=7kmod10+1
Keys:22,41,53,46,30,13,1,67.
Solution:
Hl(22)=0,Hl(41)=2,Hl(53)=5,Hl(46)=6,noconflict
WhenH1(30)=2,H2(30)=1(2+1*1)%11=3,so30entersthe3rdslot;
Hl(l3)=6,H2(l3)=2(6+1*2)%11=8,so13entersthe8thslot;
Hl(1)=3,H2(1)=8(3+5*8)%ll=10so1enters10(passby0,8,5,2);
H1(67)=3,H2(67)=10(3+2*10)%11=1so67entersl(passby2)
226741305346131
012345678910
8.Youaregivenaseriesofrecordswhosekeysareintegers.Therecordsarriveinthe
followingorder:C,S,D,T,A,M,P,I,B,W,N,G,U,R.Showthe2-3treethat
resultsfrominsertingtheserecords,(theprocessofyoursolutionisrequired!!!)
Solution:
9.
Thefollowinggraphisacommunicationnetw
溫馨提示
- 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)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 《酒店消防培訓(xùn)》課件2
- 孕期肛門墜脹的健康宣教
- 鼻惡性肉芽腫的健康宣教
- 《計算機輔助制》課件
- 白塞氏病的健康宣教
- 睡眠呼吸暫停綜合征的健康宣教
- 孕期室性早搏的健康宣教
- 激素依賴性皮炎的臨床護理
- 妊娠合并淋巴瘤的健康宣教
- 急性喉氣管炎的健康宣教
- 中職餐飲服務(wù)與管理-完整版PPT課件中職全套教程
- 小學(xué)信息技術(shù) 甘教版 四年級上冊 認(rèn)識計算機 課件
- 潑水節(jié)卡通兒童教學(xué)課件PPT模板
- MBA數(shù)據(jù)模型與決策考卷及答案
- 智能控制技術(shù)專業(yè)申報材料
- 大氣污染控制工程課程設(shè)計說明書(附圖紙)
- 正丁烷的理化性質(zhì)及危險特性表
- DB36T 1477-2021碳普惠平臺運營管理規(guī)范
- 日光溫室的設(shè)計與建造
- 心衰病住院臨床路徑
- 黑布林名著閱讀漁夫和他的靈魂及練習(xí)(含答案)
評論
0/150
提交評論