NTU-Exam 板


LINE

课程名称︰演算法 课程性质︰选修 课程教师︰李建模 开课学院:电资学院 开课系所︰电机系 考试日期(年月日)︰2010/06/20 考试时限(分钟):150 min 是否需发放奖励金:是 (如未明确表示,则不予发放) 试题 : Problem 1( 15 points, 5 point each )<Amortized Analysis> Use the potential method to show the amortized running time of a sequence of insertions and deletions on a red-black tree T of n nodes. A. Prove that Φ(T) is valid potential function, where k is positive constant Φ(T)=0 ,when n=0 n Φ(T)=k Σ lg i ,when n>0 i=0 B. Show the amortized cost of each insertion is O(lg n) C. Show the amortized cost of each deletion is O(1) Problem 2( 15 points, + 5 points bonus)<Maze Generator> Our class wants to start an online game website, call MazeBook, which generate a random maze each time a player login. An n x n maze can be viewed as a n x n array of cells, where the entrance is cell 0, upper left corner, and the exit is cell ( n x n ) - 1, lower right corner. We start with an n x n array with walls around each cell, except the entrance and exit. We them randomly knock down walls between two neighbor cells until there is a unique path from the entrance to every cell in the maze. That means, (1) no cell is isolated, and (2) exactly one path from entrance to each cell. The left figure is the initial 4 x 4 maze and the right figure is the finished maze. ┌─┬─┬─┬─┐ ┌───┬───┐ 0 │1 │2 │3 │ 0 1 │2 3 │ ┌─┼─┼─┼─┤ ┌─┐ └─ │ │4 │5 │6 │7 │ │4 │5 6 7 │ ├─┼─┼─┼─┤ │ └─ │ │8 │9 │10│11│ │8 9 10│11│ ├─┼─┼─┼─┘ │ ─┐ └─┘ │12│13│14│15 │12 13│14 15 └─┴─┴─┴─┘ └───┴───┘ A. As the chief p programmer of MazeBook, you are asked to fill-in the following algorithm to generate a random maze. You can call the disjoint set functions decined in the textbook. ( 10 points ) ┌─────────────────────────────────┐ │GENERATE-MAZE(n) │ │ generate n x n array of cells; │ │ knock down left wall of cell 0; // entrance │ │ knock down right wall of cell n^2 -1; // exit │ │ foreach cell i │ │ __________________; // initialize each cell │ │ while ( number of set is greater than 1 ) │ │ randomly pick two neighbor cells x,y; │ │ if ( ______________________ ) │ │ knock down wall between cell x and y; │ │ _________________________; │ │ return n x n maze; │ └─────────────────────────────────┘ B. Use the algorithm in A. Suppose that we randomly choose (x,y) pairs in the following order, show the finished 4x4 maze. ( 5 points ) (9,10) (5,6) (13,14) (4,5) (10,11) (14,15) (15,11) (0,4) (6,2) (3,7) (13,12) (4,8) (9,13) (2,3) (2,1) (8,9) C. Prove that there is one and only one path from the entrance to each cell. (bonus) Problem 3 ( 10 points ) <NP Complete> Professor McCluskey wants you to find a polynomial-time algorithm to solve the two-level logic minimization problem. Please prove to him that the set-covering problem is NP complete so there is no known polynomial-time algorithm available (yet). Hint: we already know that vertex covering is NP-complete. Problem 4 ( 15 points )<All pairs shortest paths> Our MazeBook company is very successful and we have five branch offices all over the world. The traveling costs between five branches are given in the flowing graph. As the CEO of this company, you need to travel between branch offices very often. To save your traveling cost, please find the shortest paths between all pairs of branch offices. 3 (1)────→(2) ↑↖7 ╱│ ╲3 │ ╲ ╱ │ ↘ 5│ ╳ │2 (5) │ ╱ ╲ │ ↗ │↙4 ╲↓ ╱-2 (4)←────(3) 1 A. Use the FASTER-ALL-PATHS-SHORTEST-PATHS algorithm in the textbook. Show all your intermediate results: L(1) L2)... ( 5 points ) B. Use the Floyd-Warshall algorithm. Show all your intermediate results: D(0) Π(0) D(1) Π(1)... ( 10 points ) Problem 5 ( 15 points, 5 points each) <Maximum Flow> Given the following flow network G. 5 (1)────→(2) ↑↖1 ↗│ ╲9 │ ╲ ╱ │ ↘ 2│ ╳ │2 (t) │ ╱ ╲ │ ↗ │╱3 ╲↓ ╱1 (s)←────(3) 5 A. What is the mincut c(S,T) of this flow network? B. For your answer in A, what is the maximum flow? C. Use the Edmonds-Karp method to find the maximum flow from s to t. Show all of your flow network G in each iteration. When two paths are of the same length, always choose the smaller vertex number first. Problem 6 ( 15 points )<Minimum Spanning Tree> Given the following graph where each edge is associated with a weight. 2 2 (b)───(e)───(h) 13 ╱ ╲3 ╲ ╲4 ╱ 7 ╲ 5 ╲15 ╲ (a)───(d)───(g) (j) ╲ ╱ ╲ ╲ ╱ 11 ╲ ╱7 ╲2 2 ╲ ╱9 (c)───(f) (i) 1 A. Find the minimum-weight spanning tree by Kruskal's algorithm. Show your answer step by step. ( 7 points ) B. Find the minimum-weight spanning tree by Prim's algorithm starting from vertex a. Show your answer step by step. ( 8 points ) Notes: 1. Please write down the edge added into the MST in each step. e.g. (a,c)→ (c,d)→(g,i). No need to draw al graphs. 2. If two edges tie, choose the edge that comes first in dictionary order. e.g. choose (b,e) before (d,f) Problem 7 ( 10 points )<greedy algorithm on MST> Suppose you gave an undirected graph with weighted edges. You perform a depth-first search, such that the edge going out of each vertex are always explored in increasing order of their weights, smallest first. Is the resulting depth first search tree guaranteed to be a minimum spanning tree? If so, please explain why. If it isn't, please provide a counterexample, showing the greedy DFS tree ( with starting vertex ) and the MST. Problem 7 ( 5 points ) Please give two things that should be improved for the class. What is the most valuable thing that you have learned from the class? What is your favorite topic? What is the worst topic? end --



※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.250.13
1F:→ ji394vul3m6 :为什麽我一个字一个字打才7元= = 06/20 19:47
2F:→ ji394vul3m6 :有人能帮我解惑吗... 会不会太扯了 06/20 19:50
※ 编辑: ji394vul3m6 来自: 140.112.250.13 (06/20 19:50)
3F:→ a3225737 :如果有某部份复制贴上的话会扣 06/20 19:57
4F:→ ji394vul3m6 :我全部都手打的= = 崩溃 06/20 19:57
5F:→ tantofish :你有使用暂存档 或是断线重贴过吗@@? 06/20 20:02
6F:→ ji394vul3m6 :没有 就中间有吃个东西再继续打= = 该不会是吃东西 06/20 20:07
7F:→ ji394vul3m6 :的时间会扣= = 06/20 20:07
8F:推 ketsu1109 :已收入 06/20 20: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灯, 水草

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

TOP