NTU-Exam 板


LINE

课程名称︰演算法 课程性质︰系必修 课程教师︰蔡益坤 开课学院:管理学院 开课系所︰资讯管理学系 考试日期(年月日)︰2011/06/20 考试时限(分钟):180分钟 是否需发放奖励金:是 (如未明确表示,则不予发放) 试题 : Note This is a closed-book exam. Each problem accounts for 10 points, unless otherwise marked. Problems 1. For each of the following pairs of functions, determine whether f(n) = O(g(n)) and/or f(n) = Ω(g(n)). Justify your answers. f(n) g(n) (a) (log n)^(log n) n / (log n) (b) (n^3) ×(2^n) 3^n Note: the suggested solution to this midterm exam problem is not quite complete. Please try to do better. 2. Consider rearranging the following array into a max heap using the bottom-up approach. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ┌─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┐ │2 │8 │3 │5 │1 │14│6 │7 │11│4 │10│12│13│15│9 │ └─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┘ Please show the result (i.e., the contents of the array) after a new element is added to the current collection of heaps (at the bottom) until the entire array has become a heap. 3. Prove that the sum of the heights of all nodes in a complete binary tree with n nodes is at most n-1. You may assume it is known that the sum of the heights of all nodes in a full binary tree height h is 2^(h+1)-h-2. (Note: a single-node tree has height 0.) 4. Compute the next table as in the KMP algorithm for string B[1..11] = abaabababaa. Please show how next[7] and next[11] are computed from using preceding entries in the table. 5. Given as input a connected undirected graph G, a spanning tree T of G, and a vertex v, design an algorithm to determine whether T is a valid DFS tree of G rooted at v. In other words, determine whether T can be the output of DFS under some order of the edges starting with v. Please present your algorithm in an adequate pseudo code and make assumptions wherever necessary. Explain why the algorithm is correct and give an analysis of its time complexity. The more efficient your algorithm is, the points you get for this problem. 6. What is wrong with the following algorithm for computing the minimum-cost spanning tree of a given weighted undirected graph (assumed to be connected)? If the input is just a single-node graph, return the single node. Otherwise, divide the graph into two subgraphs, recursively compute their minimum-cost spanning trees, and then connect the two spanning tree with an edge between the two subgraphs that has the minimum weight 7. Let G = (V,E) be a connected weighted undirected graph and T be a minimum -cost spanning tree (MCST) of G. Suppose that the cost of one edge {u,v} in G is increased; {u,v} may or may not belong to T. Design an algorithm either to find a new MCST or to determine that T is still an MCST. The more efficient your algorithm is, the more points you will be credited for this problem. Explain why your algorithm is correct and analyze its time complexity. 8. Let G = (V,E) be a directed graph, and let T be a DFS tree of G. Prove that the intersection of the edges of T with the edges of any strongly connected component of G form a subtree (rather than two or more separate subtrees) of T. 9. Below is a solution to the single-source shortest path problem using the dynamic programming approach, which we have discussed in class: Denote by DL(u) the length of a shortest path from v (the source) to u containing at most l edges; particularly, D(u)^(n-1) is the length of a shortest path from v to u (with no restrictions). length(v,u) if (v,u) belong to E DL(u) = 0 if v = u ∞ otherwise DL(u) = min{ D(L-1)(u), min {D(L-1)(u') + length(u',u)}}, (u',u belong to E) 2≦L≦n-1 Please explain why the solution allows edges with a negative weight (as long as there is no cycle with a negative weight). How is this different from Dijkstra's algorithm? Please explain. 10.The subgraph isomorphism problem is as follows. Given two graphs G1 = (V1,E1) and G2 = (V2,E2), does G1 have a subgraph that is isomorphic to G2? (Two graphs are isomorphic if there exists a one-one correspondence between the two sets of vertices of the two graphs that preserves adjancency, i.e., if there is an edge between two vertices of the first graph, then there is also an edge between the two corresponding vertices in the second graph, and vice versa.) Prove that the subgraph isoporphism problem is NP-complete. (Hint: the proof of NP-hardness is by reduction from the Hamiltonian Cycle problem, we set G1 = (V1,E1) to be precisely the same as G and G2 = (V2,E2) to be a ring of |V1| nodes for the input to the subgraph isoporphism problems.) Appendix The Hamiltonian cycle problem: give an undirected graph G, does G have a Hamiltonian cycle? (A Hamiltonian cycle in a graph is a cycle that contains each vertex, except the starting vertex of the cycle, exactly one.) The Hamiltonian cycle problem is NP-complete. --



※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.245.126
1F:→ ahau : 呜呜没有答案 06/20 22:22







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

请输入看板名称,例如:Soft_Job站内搜寻

TOP