NTU-Exam 板


LINE

課程名稱︰資料結構 課程性質︰電機系選修 課程教師︰吳沛遠 開課學院:電機資訊學院 開課系所︰電機系 考試日期(年月日)︰2017/11/06 考試時限(分鐘):14:20~17:20 180分鐘 試題 : 1. (30 pt) Let f: N --> R+, g: N --> R+, h: N --> R+ (a.k.a., f(n), g(n), h(n) are all positive functions with domain N, the set of positive integers.) (a) (6 pt) Give the formal definition of the following: (i) f ∈ O(g) (ii) f ∈ θ(g) (b) (6 pt) Prove that the big- Oh relation satisfies the following properties: (i) Reflexivity: f ∈ O(f) (ii) Transitivity: If f ∈ O(g), g ∈ O(h), then f ∈ O(h) (c) (4 pt) Prove that if f ∈ O(g), g ∈ O(f), then f ∈ θ(g) (d) (6 pt) Prove that the big- Theta relation satisfies the following three properties: (i) Reflexivity: f ∈ θ(f) (ii) Transitivity: If f ∈ θ(g), g ∈ θ(h), then f ∈ θ(h) (iii) Symmetry: If f ∈ θ(g), then g ∈ θ(f) In fact, those three properties imply that θ is an equivalence relation. (e) (8 pt) Order the following list of functions by the big- Oh notation in non- decreasing order. Group together(for example, by cycling) those functions that are big- Theta of one another. The logarithmic function is base of 2. 9n^(2/3) (2017n)^(1/2) 10^(10^100) log log n 2n + 2^n 3^n n^(2/3)*logn 10^100 * n + 10^(-100) * n^2 2^(2logn) 11*n^(1/2) 3*n^(3/2) + n 10^(-100)*0.5^n n^2 * log(n^5) n^n log(n^n) log(n!) n^(2^100) 2. (15 pt) Find a closed form solution of T(n) in big- Theta notation. Derivation is not required but may lead to partial credits in case your answer is incorrect. (a) (3 pt) T(n) = 9T(n/3) + n^2(log n)^2 (b) (3 pt) T(n) = 10T(n/3) + n^2(log n)^2 (c) (3 pt) T(n) = T(n^(1/2)) + 1 (d) (3 pt) T(n) = 3T(n - 1), T(1) = 1 (e) (3 pt) T(n) = 5T(n - 1) - 6T(n - 2), T(1) = 1, T(2) = 5 3. (20 pt) (a) (10 pt) Write a pseudo- code to compute the greattest common divisor(gcd, 最大公因數) between two positive integers. (b) (5 pt) Illustrate how your algorithm works to find the gcd between 62 and 36. (c) (5 pt) Analyze the worst-case time complexity (in big-Oh notation) of your algorithm. 4. (20 pt) Alice is a kindergarten teacher. She wants to give some candies to the children in her class. All the children sit in a line (their position is fixed), and each of them has a rating score according to his or her performance in the class. Alice wants to give at least 1 candy to each child. If two children sit next to each other, then the one with the higher rating must get more candies. Alice wants to save money, so she needs to minimize the total number of candies given to children. (a) (5 pt) Suppose there are 20 students in Alice's class with ratings as in the table below. Please fill up the table with the number of candies to be given to each student as well as the total amount of candies given. ID Rating Candies 1 14 2 11 3 13 4 6 5 16 6 3 7 5 8 10 9 15 10 1 11 19 12 7 13 2 14 20 15 4 16 12 17 18 18 17 19 19 20 8 Total: _____ candies (b) (10 pt) Write a pseudo-code to solve the problem with Input: Rating of each stuednt r_1, r_2, ..., r_n Output: Candies for each student c_1, c_2, ..., c_n (c) (5 pt) Analyze the worst-case time complexity (in big-Oh notation) of your algorithm. 5. (25 pt) Consider the following scnario. You have a sequence of numbers 1, 2 ,..., n and an empty stack. At each step you may choose to either (1) push a number into stack in order (a.k.a, First time push 1, second time push 2, and so on), or (2) pop a number to the output. After all numbers are pushed in or poped out, the output will be a permutation of 1, ..., n. For example, when n = 3, one may get the output 2,3,1 as follows: Step 1: push 1 Step 2: push 2 step 3: pop 2 step 4: push 3 step 5: pop 3 step 6: pop 1 (a) (6 pt) If n = 10, is it possible to achieve the following outputs? Please either list the steps to achieve the output, or explain why the output is impossible. (i) 3,5,6,4,7,9,8,2,10,1 (ii) 7,6,8,5,3,10,9,4,2,1 (b) (4 pt) Let a_n be the number of possible outputs when the input is 1,2,... ,n. Compute a_4, a_5, a_6, a_7 (c) (4 pt) Denote a_0 = 1, prove the following recurrence relation holds for each n >= 1 n-1 a_n = Σ a_k * a_n-k-1 k=0 (d) (8 pt) Solve a_n. Please show your derivation.(Hint: Define A(z) = Σa_n * z^n, prove that z[A(z)]^2 - A(z) + 1 = 0. You may assume the series Σa_n * z^n absolutely converge at |z| < r for some r > 0.) (e) (3 pt) If the stack data sturcture is replaced by a queue as follows, what is the number of all possible outputs when the input is 1, 2, ..., n ? Please elaborate your reasons. --



※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.112.25.121
※ 文章網址: https://webptt.com/m.aspx?n=bbs/NTU-Exam/M.1547970730.A.CCE.html
1F:→ zero : 已收電機系 05/07 15:57







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

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

TOP