



下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quá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)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 上海各區(qū)初中言議論文考題選
- 4.3 平面鏡成像 說課稿 2025年初中人教版物理八年級上冊
- 賓館消防安全管理制度
- 合作協(xié)議的定價
- 任務(wù)未完成檢討書
- 委托書無效可以變更
- 寵物運輸國內(nèi)服務(wù)協(xié)議
- 航運貨物延誤答辯狀
- 二零二五年度北京市體育館體育活動組織及推廣合同
- 模具產(chǎn)業(yè)園項目可行性研究報告
- (一模)東北三省三校2025年高三第一次聯(lián)合模擬考試 生物試卷(含答案)
- 金屬熔融崗位培訓課件
- 污水處理廠工程設(shè)備安裝施工方案及技術(shù)措施
- 2025年海南??谑兴畡?wù)局招聘事業(yè)單位人員35人歷年高頻重點模擬試卷提升(共500題附帶答案詳解)
- 2025年關(guān)聯(lián)公司資金往來協(xié)議
- 交警大隊合同范本
- 產(chǎn)業(yè)轉(zhuǎn)移課件-2024-2025學年高三一輪復習人教版(2019)地理選擇性必修2
- 2025年02月中國科協(xié)所屬單位公開招聘社會在職人員14人筆試歷年典型考題(歷年真題考點)解題思路附帶答案詳解
- 2025-2030年中國電動滑板車市場運行動態(tài)及發(fā)展規(guī)劃分析報告
- 2025年江蘇鹽城市交通投資建設(shè)控股集團有限公司招聘筆試參考題庫附帶答案詳解
- 事故隱患內(nèi)部舉報獎勵制度
評論
0/150
提交評論