作者zkdzvy22 (逍遙山水)
看板Grad-ProbAsk
標題Re: [理工] [資結]-94台大-電機資結
時間Fri Feb 26 14:32:56 2010
※ 引述《gpu (GraphicProcessUnit)》之銘言:
: http://www.lib.ntu.edu.tw/exam/graduate/94/452.pdf
: 我想請問
: 第三題
: Let the value of the postfix expression
: AB+D*EBA//+AD*C/+CD*+A-B+CD*-
: be y. Then y mod 5 =?
: 解答給1但是我算是2
: 可以幫我看一下嗎~"~
(A+B)*D+E/(B/A)+A*D/C+C*D-A+B-C*D
(1+2)*4+5/(2/1)+1*4/3+3*4-1+2-3*4
=17
就算變成中序算出來還是跟你一樣(炸
: 第11題
: Suppose a tree with only one node is defind to be with height 1.
: Let x be the maxium height of an AVL tree with 400 nodes.
: Then, x mod 5 = ?
: (A) 0 (B) 1 (C) 2 (D) 3 (E) 4
: Ans : C
我不太會畫圖 用手畫觀察出下列情況
0 n=1,h=1
/ \
0 0 n=2,3,h=2
/ \ /
0 00 n=4,5,6,h=3
/
. n=7,8,9.10,h=4
.
.
==>n(n+1)/2<=400
n<=27.xxxx
最大27 27mod5=2
: 第12題
: Suppose a tree with only one node is defined to be with height 1.
: Let y be the minimum height of an AVL tree with 400 nodes.
: Then, y mod 5 = ?
: (A) 0 (B) 1 (C) 2 (D) 3 (E) 4
: Ans : E
AVL tree最小高度就每層放滿
1(2^n-1)/(2-1)>=400
n>=8.xxxx
最小9 9mod5=4
: 還有第16題的Deap
: 解答給
: 左子樹
: 5
: / \
: 7 18
: / \
: 14 27
: 右子樹
: 35
: / \
: 30 25
: 但是我做出來是
: 左子樹
: 5
: / \
: 7 14
: / \
: 25 27
: 右子樹
: 35
: / \
: 30 18
: 請幫我看一下
: 謝謝
這題我的答案跟你一樣QQ
以上有錯請幫我糾正XDD
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 125.229.249.184
→ EntHeEnd:那個式子裡面有5/2 和 4/3 怎嚜算到17的... ? 02/26 15:50
推 strangehead:中序一開始E就轉錯了吧?? 02/26 15:57
→ strangehead:呃~我眼殘 沒事 02/26 15:58
→ strangehead:我算是1沒錯... 02/26 16:02
→ EntHeEnd:那請問那個5/2 和 4/3 跑哪去了... 02/26 16:07
→ EntHeEnd:那個infix有錯嗎 ? 02/26 16:08
→ strangehead:infix我算是對的,但是答案出來是16(不取整數是16.833 02/26 16:16
→ EntHeEnd:.........所以要四捨五入嗎 XD 02/26 16:17
→ EntHeEnd:我算到分數就覺得怪怪的 02/26 16:17
→ EntHeEnd:四捨五入應該是17吧 ? 02/26 16:18
→ strangehead:用程式語言來算的話,5/2=2 不會四捨五入 02/26 16:19
→ EntHeEnd:.........要拐這麼多圈喔... 02/26 16:22
→ strangehead:呃...算的時候就直接取整數就好啦,把自己當compiler 02/26 16:26
→ EntHeEnd:一般計算習慣會四捨五入吧 除非題目強調要考慮是程式... 02/26 16:31
推 supergud:遇到分數直接取整數 要以COMPILER的方式去TRACE 02/26 16:37
推 EntHeEnd:嗯嗯 感謝討論 02/26 16:38
推 supergud:deap跟你一樣 02/26 16:40
→ EntHeEnd:不過 是在最後無條件捨去 還是過程中就可以無條件捨去XD? 02/26 16:43
→ EntHeEnd:如果他每個變數都用int存 小數應該在過程中就被捨去了 02/26 16:44