NTU-Exam 板


LINE

課程名稱︰演算法設計與分析 課程性質︰必帶 課程教師︰蔡欣穆 開課學院:電機資訊學院 開課系所︰資訊工程學系 考試日期(年月日)︰101/1/13 考試時限(分鐘):180 是否需發放獎勵金:是 (如未明確表示,則不予發放) 試題 : Algorithm Design and Analysis, Fall 2011 Final Examination 120 points Time: 9:10am-12:10pm(180 minutes),Friday, January 13, 2012 Problem 1. In each of the following question, please specify if the statement is true or false. If the statement is true, explain why it is true. If it is false, explain what the correct answer is and why.(8 points. 1 point for true /false and 3 points for the explanation for each question) 1.The complexity class NP represents the problems which cannot be solved in polynomial time. 2.When the parallelism of a multi-thread algorithm, ρ=Ω(n), adding more processors to the system which runs the algorithm would always make the algorithm run faster. Problem 2. "Short answer" questions:(36 points) 1.Why is it hard to discover bugs caused by race conditions?(4 points) 2.Fill in blanks (a) through (d) in Figure 1 using T1(A),T1(B),T∞(A), and T∞(B).(8 points) ┌─┐ │A │ ┌──┐ ┌──┐ ↗└─┘↘ ─→│ A │─→│ B │─→ ↗ ↘ └──┘ └──┘ ↘ ┌─┐ ↗ ↘│B │↗ └─┘ Work:T1 (A∪B)=(a) Work:T1 (A∪B)=(c) Span:T∞(A∪B)=(b) Span:T∞(A∪B)=(d) Figure 1: The work and span of composed subcomputations 3.What are the two conditions that a language L ⊆ {0,1}* is NP- complete?(4 points) 4.Explain why Dijkstra's algorithm does not work when the edges in the graph can be negative.(4 points) 5.Explain when using Evidence-Based Scheduling, how we predict the time to complete a task.(4 points) 6.List two advantages of writing the functional specification before start implementing the software.(4 points) 7.Let T∞, Tp, T1 be the running time of multi-threaded algorithm A when having ∞,P,1 processors in the system, respectively. Write down the formulas for (1)the work law; and (2)the span law; using these 3 variables. (8 points) X1──| ̄ ̄╲ ╴╴ X2──| )──── ╲ ╲ ┌─|╴╴╱ ∣ ╲ X3┴──────────| >── ────∣ ╱ ╱ ╱ ╱ |╲ ╱  ̄ ̄ X4─| O╴╱ |╱ Figure 2 : A Boolean Combinational Circuit Problem 3.Please answer the following questions about circuit satisfiability and formula satisfiability problems: (22 points) 1.Use the reduction algorithm we talked about in the lecture to reduce the circuit in Figure 2 to a general boolean formula.(4 points) 2.Use the reduction algorithm we talked about in the lecture to reduce a general boolean formula (~X1 ^ X2) V X3 to the 3-CNF form.(8 points) 3.In the class, we talked about how 3-CNF formula is a restricted form of the boolean formula, and how we do not want to restrict the form too much so that it is no longer a NP-complete problem anymore. 2-CNF formula is an example of restricting the form too much. Let 2-CNF-SAT be the set of satisfiable boolean formulas in CNF with exactly 2 literal per clause. Show that 2-CNF-SAT ∈ P. Make your algorithm as efficient as possible.(Hint: Observe that x V y is equivalent to ~x→y. Reduce 2-CNF-SAT to an efficient sovlable problem on a directed graph.) (10 points) Problem 4. Consider an ordinary binary min-heap data structure with n element supporting the instructions INSERT and EXTRACT-MIN in O(log n) worst-case time. Give a potential function Φ such that the amortized cost of INSERT is O(log n) and the amortized cost of EXTRACT-MIN is O(1), and show that it works :(Hint: one way to formulate the potential function involves the depths of the nodes in the heap. Think of a way to combine them.) (20 points) 1.Define your potential function Φ. Prove that it always satisfies Φ(Di)≧Φ(D0), ∀i, where Di is the data structure after performing the i-th operation.(4 points) 2.Show that the amortized cost of INSERT is O(log n).(8 points) 3.Show that the amortized cost of EXTRACT-MIN is O(1).(8 points) Problem 5. Answer the following questions about the complexity class co-NP. (12 points) 1. Use the language HAM-CYCLE ={﹤G﹥:G is a hamiltonian graph} as an example to explain what co-NP means; on what condition HAM-CYCLE ∈NP? (4 points) 2.Prove that P ⊆ co-NP. (8 points) Problem 6. Answer the following questions about graph.(20 points) 1.Use Prim's algorithm to obtain the minimum spanning tree of the graph in Figure 3. Please mark the order of adding the edge to the spanning tree on the figure. (4 points) 2.Please use the Bellman-Ford algorithm to determine the costs of the shortest paths (the number next to the edges in the graph are the costs for traveling through them) from vertex 1 to all other vertices in the graph in Figure 3. Use table 1 to show how the algorithm is executed in each iterations.(8 points) 3.Please use the Dijkstra's algorithm to determine the costs of the shortest path(the number next to the edges in the graph are the costs for traveling through them) from vertex 1 to all other vertices in the graph in Figure 3. Use Table 2 to show how the algorithm is executed in each iteration.(8 points) ⑤ ④ 2╱ ╲4 1╱ ╲3 ╱ 9 ╲ ╱ 5 ╲ ① ──── ⑦─────② ╲ ╱ ╱ 20╲ 10╱ ╱3 ╲ ╱ 2 ╱ ⑥────③ Figure 3: A Graph ┌─┬───────────┐ │ │ k │ │ │ dist [7] │ │k ├─┬─┬─┬─┬─┬─┤ │ │2 │3 │4 │5 │6 │7 │ └─┴─┴─┴─┴─┴─┴─┘ ┌─┬─┬─┬─┬─┬─┬─┐ │1 │∞│∞│∞│2 │20│9 │ ├─┼─┼─┼─┼─┼─┼─┤ │2 │ │ │ │ │ │ │ ├─┼─┼─┼─┼─┼─┼─┤ │3 │ │ │ │ │ │ │ ├─┼─┼─┼─┼─┼─┼─┤ │4 │ │ │ │ │ │ │ ├─┼─┼─┼─┼─┼─┼─┤ │5 │ │ │ │ │ │ │ ├─┼─┼─┼─┼─┼─┼─┤ │6 │ │ │ │ │ │ │ └─┴─┴─┴─┴─┴─┴─┘ Table 1 : Step-by step execution details of the Bellman-Ford algorithm ┌─────┬────────┬───────────┐ │ │ │ Distances │ │Iteration │Vertex Selected ├─┬─┬─┬─┬─┬─┤ │ │ │2 │3 │4 │5 │6 │7 │ └─────┴────────┴─┴─┴─┴─┴─┴─┘ ┌─────┬────────┬─┬─┬─┬─┬─┬─┐ │ Initial │ ─ │∞│∞│∞│2 │20│9 │ ├─────┼────────┼─┼─┼─┼─┼─┼─┤ │ 1 │ │ │ │ │ │ │ │ ├─────┼────────┼─┼─┼─┼─┼─┼─┤ │ 2 │ │ │ │ │ │ │ │ ├─────┼────────┼─┼─┼─┼─┼─┼─┤ │ 3 │ │ │ │ │ │ │ │ ├─────┼────────┼─┼─┼─┼─┼─┼─┤ │ 4 │ │ │ │ │ │ │ │ ├─────┼────────┼─┼─┼─┼─┼─┼─┤ │ 5 │ │ │ │ │ │ │ │ ├─────┼────────┼─┼─┼─┼─┼─┼─┤ │ 6 │ │ │ │ │ │ │ │ └─────┴────────┴─┴─┴─┴─┴─┴─┘ Table 2 : Step-by-step execution details of Dijkstra's algorithm Problem 7. Out of all topics we covered in the classes this semester, which one do you like the most? Which one do you dislike the most? Why? Please give some constructive suggestions. (2 points) --



※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.244.207
1F:推 so15963 :推 01/14 23:37
2F:推 wctaiwan :好精美 01/15 00:28
3F:→ NiFuTe :這一篇文章值 1000 Ptt幣 01/15 01:46
4F:推 a123zyx :本想PO但有表格就懶了XDD 01/15 02:25







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燈, 水草

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

TOP