Grad-ProbAsk 板


LINE

12.Consider the following program. void main() { printf("%4d",f(95) ); } int f(int n) if(n>100) return (n-10); return (f(f(n+11))); } (26).The output is an integer. How many digits are there? (A)1 (B)2 (C)3 (D)4 (E)5 公佈答案:(B) (我認為是D) 原因:執行f(95)的結果是91 但是"%4d" 不論是2位數或3位數甚至是5位數,都是印出4位數 14.Given a weighted graph and two vertices s and t, we want to find a longest path from s to t. Which of the following statements are WRONG aboout this problem? Select the correct answers from the following 2 questions. i. This problem has a polynomail time algorithm. ii. This prombel can be solved by transforming it into shortest path problem. iii. This problem can be solved by using Dynamic Programming. iv. For a connected weighted graph the longest path has at least 3 edges. v. For a graph with n vettices. if the longest path has n-1 edges, then it passes through each vertex exactly once. 公佈答案:i,ii,iv (我認為是i,ii,iii,iv) 原因:longest path是NP-Complete Problem可用Dynamic Programming解? 18.Please finish the following implementation of circular queue. class Queue { private: int orz,a,b; int data[3]; public: Queue() { orz=0; a=-1; b=0; } void Enqueue(int x) { if(IsFull()) { cout<<"Queue is full"<<endl; reutrn; } a=(a+1)%3; data[a]=x; if((a+1)%3==b) orz=1; } int Dequeue(void) { int x; if(IsEmpty()) { cout<<"Queue is empty"<<endl; return -1; } orz=0; x=data[ (42) ]; b%=3; return x; } int IsEmpty(void) { return (orz==0 && ((a+1)%3==b ? (43); } int IsFull(void) { return (orz==1) ? (44); } }; (42) (A)b (B)b++ (C)++b (D)b-- (E)--b 公佈答案(B) (我認為是C) 原因:從Enqueue程式中的a=(a+1)%3; data[a]=x; 可以看出他是先把a指標(即Rear)前進,之後再放data 因此在Dequeue時b指標(即Front)也要先前進,才能取出data 否則b指標所指內容可能是空的,產生擷取到錯誤的資料情形發生 20. (48)Consider the case of inserting 10,8,12,6,4,2,11,1 into an empty min heap.Please show the first visited node when using LVR to traverse theresultant tree. (A)11 (B)10 (C)8 (D)12 (E)6 公佈答案(B) (我認為是C,B也沒錯,若用Top-down方式建立,答案是B) 原因:從題組4可發現到採用Bottom-up方式建立max heap 因此這題我也採用Bottom-up方式建立min heap,如下所示 1 / \ 4 2 / \ / \ 6 10 12 11 / 8 LVR我想應該是inorder traversal 因此第一個拜訪的點應該是8 --



※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 60.244.36.162 ※ 編輯: crazykk 來自: 60.244.36.162 (03/16 14:39) ※ 編輯: crazykk 來自: 60.244.36.162 (03/16 14:43)
1F:→ Lukewind:12題應該是你誤會了 %md 是輸出寬度m的,不夠用空格補 03/16 14:42
2F:→ Lukewind:18.也是a初始是-1 假如先++b第一輪應該就會錯了 03/16 14:44
3F:→ Lukewind:最長路徑問題也確實可用DP解 GOOGLE有演算法 03/16 14:46
4F:推 allenbody:20題他有強調一開始為空,用插入方式,這樣就是top down 03/16 14:47
5F:→ crazykk:恩恩,感謝各位回答,讓我死心了... 03/16 14:48
6F:→ allenbody:我沒帶考卷在身邊,有人可以PO一下或SCAN一下考題嗎?THX 03/16 14:48
7F:→ EntHeEnd:請問哪邊有公佈答案呢 ? 03/16 15:12
8F:推 willow02:有人要提出對OS的質疑嗎?XDD 03/16 15:17
9F:→ crazykk:99交大選擇題解答 http://0rz.tw/x4ZH7 03/16 15:22
10F:推 EntHeEnd:喔喔 感謝 03/16 15:27
11F:推 assassin88:OS的第十六題的D FCFS那個選項對吧? 03/16 15:27
12F:→ crazykk:回應樓上,SSTF(253) Look(253) SCAN(319) C-Look(265) 03/16 15:34
13F:→ crazykk:FIFO(300) SCAN比FIFO更久 03/16 15:36
14F:推 r5011057:請問OS第10.11題是怎麼算的? 03/16 16:00
15F:→ keepoo:11.link要從頭讀起 所以┌422/128┐=3 03/16 16:02
16F:→ keepoo:我錯了 XD 歹勢 腦袋糊塗 03/16 16:05
17F:→ LATTICE:第12題答案沒錯,"%d"只是預留4個空間而已,不會補0 03/16 16:12
18F:推 abcde1499:queue那題我也覺得是++b @@ 03/16 16:44
19F:推 sean721:我也寫++b.....〒△〒 03/16 17:03
20F:推 fish0112:DS&Algo雖然考選擇,但是感覺很難 尤其對會懷疑自己的人 03/16 17:07
21F:→ fish0112:小弟就是@rz 03/16 17:07
22F:→ fish0112:不應該猜這麼多的...(哭哭) 03/16 17:08
23F:推 Anthony53:LINK LIST那題為什麼不是三? 03/16 18:01
24F:推 holik0123:資結6題 有人知道是什麼演算法嗎 03/16 18:33
25F:→ holik0123:還是只是MAX-FLOW 03/16 18:35
26F:推 haha31:OS拿幾分算高阿= = 03/16 18:46
27F:推 RoddickJoe:80 03/16 19:06
28F:推 lineageorc:我也寫++b說.. 03/16 19:30
29F:推 w8formePlz:80喔 那還好 03/16 19:56
30F:推 pp393952:題組第20的(48) 我填C 這樣會算對嗎... 03/16 20:01
31F:推 haha31:錯一個全錯吧. 03/16 20:17
32F:推 tom21tom21:有沒有要寫去釋義 03/16 20:24
33F:推 uthtdwp:請問資結第41題答案確定是(c)嗎 我算是(d)? 03/16 22:35
34F:推 Lukewind:41題 前面係數要是4才會是d 03/16 23:05
35F:推 sai31312:如果tree只有一個node那依據bipartite的定義, 03/17 00:45
36F:→ sai31312:怎麼分成兩個subsets? 03/17 00:47
37F:→ sai31312:所以22 23 我寫E耶 03/17 00:48
38F:推 sai31312:還有我可以問一下第二題hash的答案是怎麼來的嗎? 03/17 01:00
39F:推 sai31312:而且OS的第11題我也覺得很怪,他給的是logical address 03/17 01:13
40F:推 sai31312:可是沒有說清楚logical physical之間的對應 03/17 01:23
41F:→ sai31312:是怎麼知道必要讀取4個physical block才到的了 03/17 01:23







like.gif 您可能會有興趣的文章
icon.png[問題/行為] 貓晚上進房間會不會有憋尿問題
icon.pngRe: [閒聊] 選了錯誤的女孩成為魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一張
icon.png[心得] EMS高領長版毛衣.墨小樓MC1002
icon.png[分享] 丹龍隔熱紙GE55+33+22
icon.png[問題] 清洗洗衣機
icon.png[尋物] 窗台下的空間
icon.png[閒聊] 双極の女神1 木魔爵
icon.png[售車] 新竹 1997 march 1297cc 白色 四門
icon.png[討論] 能從照片感受到攝影者心情嗎
icon.png[狂賀] 賀賀賀賀 賀!島村卯月!總選舉NO.1
icon.png[難過] 羨慕白皮膚的女生
icon.png閱讀文章
icon.png[黑特]
icon.png[問題] SBK S1安裝於安全帽位置
icon.png[分享] 舊woo100絕版開箱!!
icon.pngRe: [無言] 關於小包衛生紙
icon.png[開箱] E5-2683V3 RX480Strix 快睿C1 簡單測試
icon.png[心得] 蒼の海賊龍 地獄 執行者16PT
icon.png[售車] 1999年Virage iO 1.8EXi
icon.png[心得] 挑戰33 LV10 獅子座pt solo
icon.png[閒聊] 手把手教你不被桶之新手主購教學
icon.png[分享] Civic Type R 量產版官方照無預警流出
icon.png[售車] Golf 4 2.0 銀色 自排
icon.png[出售] Graco提籃汽座(有底座)2000元誠可議
icon.png[問題] 請問補牙材質掉了還能再補嗎?(台中半年內
icon.png[問題] 44th 單曲 生寫竟然都給重複的啊啊!
icon.png[心得] 華南紅卡/icash 核卡
icon.png[問題] 拔牙矯正這樣正常嗎
icon.png[贈送] 老莫高業 初業 102年版
icon.png[情報] 三大行動支付 本季掀戰火
icon.png[寶寶] 博客來Amos水蠟筆5/1特價五折
icon.pngRe: [心得] 新鮮人一些面試分享
icon.png[心得] 蒼の海賊龍 地獄 麒麟25PT
icon.pngRe: [閒聊] (君の名は。雷慎入) 君名二創漫畫翻譯
icon.pngRe: [閒聊] OGN中場影片:失蹤人口局 (英文字幕)
icon.png[問題] 台灣大哥大4G訊號差
icon.png[出售] [全國]全新千尋侘草LED燈, 水草

請輸入看板名稱,例如:BabyMother 或 站內搜尋

TOP