




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、數(shù)據(jù)結(jié)構(gòu)第六次作業(yè)選擇題1.表達(dá)式x*(y-z)+u的逆波蘭式(后綴表達(dá)式)表示是()。A)xyzuu-+B)xyz-*u+C)xyz*-u+D)+-*xyzuB規(guī)則:如表達(dá)式為數(shù)或者簡(jiǎn)單變量,則相應(yīng)二叉樹中只有一個(gè)根節(jié)點(diǎn),其數(shù)據(jù)域存儲(chǔ)此表達(dá)式信息;如表達(dá)式=(第1操作數(shù))(運(yùn)算符)(第2操作數(shù)),則相應(yīng)的二叉樹中以左子樹表示第1操作數(shù),右子樹表示第2操作數(shù),根節(jié)點(diǎn)的數(shù)據(jù)域存儲(chǔ)運(yùn)算符,操作數(shù)本身又可以為表達(dá)式。1設(shè)有表達(dá)式:a*(b-c)/d+f/(g+h*i),試給出此表達(dá)式的下面結(jié)果:二叉樹表示;逆波蘭式表示;中綴表示;綜合題逆波蘭式表示(后綴即為左右根): abc-*d/fghi*+/+
2、中綴表示(即為左根右): a*b-c/d+f/g+h*i3已知下列字符A、B、C、D、E、F、G的權(quán)值分別為3、12、7、4、2、8、11,試求對(duì)應(yīng)哈夫曼樹。步驟如下:(1) 將w1、w2、,wn看成是有n 棵樹的森林(每棵樹僅有一個(gè)結(jié)點(diǎn));(2) 在森林中選出兩個(gè)根結(jié)點(diǎn)的權(quán)值最小的樹合并,作為一棵新樹的左、右子樹,且新樹的根結(jié)點(diǎn)權(quán)值為其左、右子樹根結(jié)點(diǎn)權(quán)值之和;(3)從森林中刪除選取的兩棵樹,并將新樹加入森林;(4)重復(fù)(2)、(3)步,直到森林中只剩一棵樹為止,該樹即為所求得的哈夫曼樹。5.28 Build the Huffman coding tree and determine the
3、 codes for the following set of letters and weights: Letter A B C D E F G H I J K L Frequency 2 3 5 7 11 13 17 19 23 31 37 41 What is the expected length in bits of a message containing characters for this frequency distribution? 209 / 83 126 / / l 42 55 71 / / / H I 24 J 34 K / / E F 17 G / D 10 /
4、5 C / A B l 00 h 010 i 011 e 1000 f 1001 j 101 d 11000 a 1100100 b 1100101 c 110011 g 1101 k 111 Ffllengthini1ii其中F代表總頻度或權(quán)值,n代表總個(gè)數(shù),li代表編碼長(zhǎng)度,fi代表頻度本題中長(zhǎng)度為 3.23445 5.25 Show the max-heap that results from running build Heap on the following values stored in an array: 調(diào)整為大頂堆 10 5 12 3 2 1 8 7 9 4 10 / 5
5、 12 / / 3 2 1 8 / / 7 9 4 (10,5,12,3,2,1,8,7,9,4) 從最后一非終端節(jié)點(diǎn)開始篩選 10 / 5 12 / / 3 4 1 8 / / 7 9 2 10 / 5 12 / / 9 4 1 8 / / 7 3 2 10 / 5 12 / / 9 4 1 8 / / 7 3 2 10 / 9 12 / / 7 4 1 8 / / 5 3 2 12 / 9 10 / / 7 4 1 8 / / 5 3 2大頂堆為12,9,10,7,4,1,8,5,3,2 證明:當(dāng)n=1時(shí),即其中的葉子節(jié)點(diǎn)數(shù)為K,滿足(K-1)*1+1=K,即成立;假設(shè)當(dāng)n=x時(shí),葉子節(jié)點(diǎn)
6、數(shù)為(K-1)x+1成立;那么當(dāng)n=x+1時(shí),某一個(gè)葉子節(jié)點(diǎn)變成非葉子節(jié)點(diǎn)則會(huì)增加K-1個(gè)葉子節(jié)點(diǎn)。即最終葉子節(jié)點(diǎn)數(shù)目為:(K-1)x+1+K-1=(K-1)(x+1)+1 成立。6.13Use mathematical induction to prove that the number of leaves in a non-empty full K-ary tree is (K-1)n+1, where n is the number of internal nodes. 6.15Find the overhead fraction for a full K-ary tree implem
7、entation with space requirements as follows: 對(duì)于滿足下面空間要求的滿K叉樹實(shí)現(xiàn)方法,計(jì)算其結(jié)構(gòu)性空間開銷比例 (a) All nodes store data, child pointers, and a parent pointer. The data field requires four bytes and each pointer requires four bytes. (b) All nodes store data and child pointers. The data field requires six-teen bytes a
8、nd each pointer requires four bytes. (c) All nodes store data and a parent pointer, and internal nodes store child pointers. The data field requires eight bytes and each pointer requires four bytes. (d) Only leaf nodes store data; only internal nodes store child pointers. The data field requires fou
9、r bytes and each pointer requires two bytes. 2k/(4+2k)4(k+2)/(16+4(k+2)4k/(16+4k)4(k+1)/(4+4(k+1)6.7 Using the weighted union rule and path compression, show the array for the parent pointer implementation that results from the following series of equivalences on a set of objects indexed by the valu
10、es 0 through 15. Initially, each element in the set should be in a separate equivalence class. When two trees to be merged are the same size, make the root with greater index value be the child of the root with lesser index value. 使用重量權(quán)衡合并規(guī)則與路徑壓縮,對(duì)下列從0到15之間數(shù)的等價(jià)對(duì)進(jìn)行合并,并給出所得樹的父指針表示法的數(shù)組表示。在初始情況下,集合中國(guó)的每個(gè)元素分別在獨(dú)立的等價(jià)類中,當(dāng)兩棵樹規(guī)模同樣大時(shí),使節(jié)點(diǎn)值較大的根節(jié)點(diǎn)作為值較小的根節(jié)點(diǎn)的子節(jié)點(diǎn)。(0, 2) (1, 2) (3, 4) (3, 1) (3, 5) (9, 11) (12, 14) (3, 9) (4, 14) (6, 7) (8, 10) (8, 7) (7, 0) (10, 15) (10, 13) 重量權(quán)衡合并規(guī)則:是在做“
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 停放車輛服務(wù)合同范本
- 加盟投資協(xié)議合同范本
- 住房購(gòu)房合同范例
- 勞務(wù)家政合同范本
- 儀器安裝服務(wù)合同范本
- 修路挖機(jī)合同范本
- 臨時(shí)增項(xiàng)合同范本
- 北京公司擔(dān)保合同范本
- 做樓房施工合同范本
- 勞務(wù)合同范本買賣
- 企業(yè)服務(wù)工作實(shí)施方案
- 信息技術(shù)ppt課件完整版
- 新湘教(湖南美術(shù))版小學(xué)美術(shù)五年級(jí)下冊(cè)全冊(cè)PPT課件(精心整理匯編)
- 家譜樹形圖模板
- 大智慧指標(biāo)公式函數(shù)大全(完整可打印版)
- 髖膝關(guān)節(jié)置換術(shù)后X線評(píng)價(jià)-PPT課件
- 蓋梁抱箍法施工計(jì)算書蓋梁抱箍法施工方案
- (完整版)涼亭施工方案
- 《中國(guó)近現(xiàn)代史綱要》上編教學(xué)案例分享
- 新加坡環(huán)境治理與保護(hù)
- 常用消防圖例
評(píng)論
0/150
提交評(píng)論