NTU-Exam 板


LINE

課程名稱︰資料結構與演算法下 課程性質︰系必修 課程教師︰蔡欣穆 開課學院:電資學院 開課系所︰資訊系 考試日期(年月日)︰2011/6/24 考試時限(分鐘):180 是否需發放獎勵金:是的,感謝 (如未明確表示,則不予發放) 試題 : 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.(12%, For each questions, 1% for the true/false answer and 3% for the explanations.) 1.Let P1 = {L為{0,1}*的父集: there exists an algorithm A that decides L in polynomial time} and P2 = {L為{0,1}*的父集: there exists an algorithm A that accepts L in polynomial time}. Then P1≠P2. 2.The person who solves the bugs should be the one to close the bug report. 3.When using the potential method to do amortized analysis, we define a potential function Φ which maps each data structure Di to a real number Φ(Di), the potential associated with teh data structure Di. To make sure that the total amortized cost gives an upper bound on the total actual cost, we usually need to make sure that Φ(Dn)≦Φ(D0). Problem 2. "Short answer" questions: (38 points) 1.Show that if one of the NP-complete problems can be solved in polynomial time, then any other NP problem can be solved in polynomial time.(5%) 2.Why is it hard to discover bugs caused by race conditions?(3%) 3.Give a short definition fo a "complete step" (in the context of multithreaded algorithms, of course). (3%) 4.What does a program manager do in a software company? (3%) 5.Define parallelism, ρ, using the work and the span of a multithreaded algorithm. What does it mean when P > ρ, where P is the number of processors in the system? Please explain(2% for the definition, 3% for the explanation.) 6.Fill in blanks (a) through (d) in Figure 1 using T1(A), T1(B), T∞(A),and T∞(B). ┌──┐ ┌──┐ work:T1(A∪B) = (a) ---> │ A │----> │ B │---> └──┘ └──┘ span:T∞(A∪B) = (b) ┌──┐ │ A │ └──┘ ↗ ↘ work:T1(A∪B) = (c) ↘ ↗ span:T∞(A∪B) = (d) ┌──┐ │ B │ └──┘ 7.The basic idea of Event-Based Scheduling is to simulate the future based on the past history of actual and estimated time to finish tasks. Explain in detail how one can use it to estimate the time to finish a task.(5%) 8.What are the 3 things that are needed in every bug report?(2% for each) Problem3.Consider the following multithreaded pseudocode for transposing an n*n matrix A in place:(18%) P-TRANSPOSE(A) 1 n = A.rows 2 parallel for j = 2 to n 3 parallel for i = 1 to j-1 4 exchange aij with aji 1.Analyze the work, span and parallelism of this algorithm.(3%) 2.Suppose that we replace the parallel for loop in line 3 of P-TRANSPOSE with an ordinary for loop. Analyze the work, span, and parallelism of the resulting algorithm.(3% each) Problem 4.Suppose that we have one machine and a set of n tasks A1, A2,...,An, each of which requires time on the machine. Each task Aj requires Tj time units on the machine(its processing time), yields a profit of Pj, and has a deadline Dj. The machine can process only one task at a time, and task Aj must run without interruption for Tj consecutive time units. If we complete task Aj by its deadline Dj, we receive a profit Pj, but if we complete it after its deadline, we receive no profit. As an optimization problem, we are given the processing times, profits, and deadlines for a set of n tasks, and we wish to find a schedulte that completes all the tasks and returns the greatese amount of profit. The processing times, profits, and deadlines are all nonnegative numbers(28%) 1.State this problem as a decision problem.(3%) 2.Show that the decision problem is NP-complete. For the purpose of reduction, you can assume that 0-1 knapsack problem is NP-complete.( We talked about 0-1 knapsack problem in the first half of the semester when we covered greedy algorithms in the lecture. To refresh your memory, the following is a description of the problem. A thief robbing a store finds n items. The ith item is worth Vi dollars and weighs Wi punds, where Vi and Wi are integers. The thief wants to take as valuable a load as possible, but he can carry at most W pounds in his knapsack, for some integer W. Which items shold he take?) (15%) 3.Give a dynamic programming lgorithm for the decision problem, assuming that all processing times are integers from 1 to n.(10%) Problem 5. Let G = (V,E) to be an undirected graph with distinct edge wights w(u,v) on each edge(u,v)屬於E. For each vertex v屬於V, let MAX(v) = argmax(u,v)屬於E{w(u,v)} be the maximum-wight edge incident on that vertex.Let Sg = {MAX(v):v屬於V} be the set of maximum-weight edges incident on that vertex, and let Tg be the maximum-weight spanning tree of G, that is, the spanning tree of maximum total weight. For any subset of E define, w(E')_ = Σ((u,v)屬於E')W(u,v). (18%) 1.Prove that Sg為Tg的子集 for any graph G.(6%) 2.Prove that w(Sg)≧W(Tg)/2 for any graph G.(6%) 3.Give an O(V+E)-time algorithm to compute a 2-approximation to the maximum spanning tree. Explain why your algorithm is a 2-approximation algorithm. (6%) Problem 6.Binary search of a sorted array takes logarithmic search time, but the time to insert a new element is linear in the size of the array. We can improve the time for insertion by keeping several sorted arrays. Specifically, suppose that we wish to support SEARCH and INSERT on a set of n elements. Let k = [㏒(n+1)], and let the binary representation fo n be <Nk-1, Nk-2,...,N0>.Ai is 2^i. Each array is either full or empty, depending on whether Ni = 1 or Ni = 0, respectively (in other words, depending on n, the number of elements stored in the array at the time). The total number of elements held in all k arrays is therefore Σ(i-0,k-1)Ni2^i = n. Although each individual array is sorted, elements in different arrays bear no particular relationship to each other. Here is how me perform the INSERT operation. We create a new sorted array of size 1 containing the new element to be inserted. If array A0(which has size 1) is empty, then we replace A0 with the new sorted array. Otherwise, we merge sort the two arrays into another sorted array of size 2. If A1 is empty, then we replace A1 with the new array; otherwise we merge sort the arrays as before and continue. Since array Ai is of size 2^im ifwe merge sort two arrays of size 2^i each, we obtain one of size 2^(i+1), which is the size of Ai+1. This method will result in another list of arrays in the same structure taht we had before. (15%) 1.Describe hwo to perform the SEARCH operation for this data structure. Analyze its worst-case running time.(6%) 2.Analyze the INSERT opertaion's worst-case and amortized running times(using the aggregate method).(3% for the worst-case, 6% for amortized) Problem 7.Feedback time again :P. This time please give us some suggestions for either the software company game we played in our last class, or general comments about the course.(6%) --



※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.193.6.232
1F:→ andy74139 :已收錄至資訊系!! 06/25 23:44







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

請輸入看板名稱,例如:Boy-Girl站內搜尋

TOP