題庫 http://www.csie.dyu.edu.tw/~spring/Exercises/search1_utf8.php ../ 科目 相關 來源 日期 題目類型 題目內容 解答 備註 file=Temp/temp80.xml algorithms binary search tree F9506037 Sat Mar 14 9:44:53 2009 證明 12.3-5 Is the operation of deletion \"commutative\" in the sense that deleting x and the y from a binary search tree leaves the same tree as deleting y and then x ? Argue why it is or give a counterexample. algorithms_55120171.odp 習題12.3-5 algorithms binary search tree F9506049 Sat Mar 14 9:28:53 2009 證明 12.1-5 Argue that since sorting n elements takes Ω(n lg n) time in the worst case in the comparison model, any comparison-based algorithm for constructing a binary search tree from an arbitrary list of n elements takes Ω(n lg n) time in the worst case. algorithms_55119211.odp 習題12.1-5 algorithms Hash Tables open addressing F9506237 Sat Mar 14 9:24:40 2009 計算 11.4-4 Consider an open-address hash table with uniform hashing. Give upper bounds on the expected number of probes in an unsuccessful search and on the expected number of probes in a successful search when the load factor is 3/4 and when it is 7/8. algorithms_55118958.odp 習題11.4-4 algorithms binary search tree red-black trees F9506219 Sat Mar 14 9:20:51 2009 問答 13.3-1 In line 16 of RB-INSERT, we set the color of the newly inserted node z to red. Notice that if we had chosen to set z\'s color to black, then property 4 of a red-black tree would not be violated. Why didn\'t we choose to set z\'s color to black? algorithms_55118729.odp 習題13.3-1 algorithms binary search tree red-black trees F9506011 Sat Mar 14 9:18:12 2009 證明 13.1-3 Let us define a relaxed red-black tree as a binary search tree that satisfies red-black properties 1, 3, 4, and 5. In other words, the root may be either red or black. Consider a relaxed red-black tree T whose root is red. If we color the root of T black but make no other changes to T, is the resulting tree a red-black tree? algorithms_55118570.odp 習題13.1-3 algorithms stack queue F9506055 Sat Mar 14 9:13:35 2009 設計演算法 10.1-7 Show how to implement a stack using two queues. Analyze the running time of the stack operations. algorithms_55118293.odp 習題10.1-7 algorithms linked list 李育德 賴宗佑 林哲賢 陳炯桓 Sat Mar 14 9:01:40 2009 基本性質 Problem 10-1 Comparisons among lists For each of the four types of lists in the following table, what is the asymptotic worst-case running time for each dynamic-set operation listed? algorithms_55117577.odp Problem 10-1 algorithms red-black trees binary search tree 曾一平 Sat Mar 14 8:55:55 2009 基本性質 13.2-3 Let a, b, and c be arbitrary nodes in subtrees α, β, and γ, respectively, in the left tree of Figure 13.2. How do the depths of a, b, and c change when a left rotation is performed on nodes x in the figure? algorithms_55117233.odp 習題13.2-3 algorithms Hash Tables F9506246 Sat Mar 14 8:52:37 2009 執行演算法 11.2-2 Demonstrate the insertion of the keys 5, 28, 19, 15, 20, 33, 12, 17, 10 into a hash table with collisions resolved by chaining. Let the table have 9 slots, and let the hash function be h(k) = k mod 9 algorithms_55117035.odp 習題11.2-2 algorithms complexity big-O spring Sat Mar 7 11:28:23 2009 證明 3.1-4 Is 2n+1 = O(2n)? Is 22n = O(2n)? (請證明您的答案) algorithms_54521581.odp 習題3.1-4 algorithms sort heap sort F9406009 Thu Feb 26 17:51:18 2009 問答 6.2-4 What is the effect of calling Max-Heapify(A, i) for i> heap-size[A]/2? algorithms_53766956.odp 習題6.2-4 algorithms sort f9406241 Thu Feb 26 17:48:02 2009 基本性質 8.3-2 Which of the following sorting algorithms are stable: insertion sort, merge sort, heapsort, and quicksort? Give a simple scheme that makes any sorting algorithm stable. How much additional time and space does your scheme entail? algorithms_53766760.odt 習題8.3-2 algorithms sort bucket-sort f9506803 Thu Feb 26 17:42:52 2009 執行演算法 8.4-1 Using Figure 8.4 as a model, illustrate the operation of Bucket-Sort on the array A = 〈.79, .13, .16, .64, .39, .20, .89, .53, .71, .42〉. algorithms_53766450.odp 習題8.4-1 algorithms sort lower bound 林煥傑 Thu Feb 26 17:38:59 2009 證明 9.1-1 Show that the second smallest of n elements can be found with n + ⌊lg n – 2⌋ comparisons in the worst case. (Hint: Also find the smallest element.) algorithms_53766217.odp 習題9.1-1 algorithms sort heap sort 桂子龍 Thu Feb 26 17:34:36 2009 證明 6.1-2 Show that an n-element heap has height ⌊lg n⌋ algorithms_53765954.odp 習題6.1-2 algorithms sort heap sort F9506213 Thu Feb 26 17:30:33 2009 證明 6.1-7 Show that, with the array representation for storing an n-element heap, the leaves are the nodes indexed by ⌊n/2⌋ + 1, ⌊n/2⌋ + 2, ..., n. algorithms_53765711.odp 習題6.1-7 algorithms sort heap sort F9506237 Thu Feb 26 17:23:43 2009 問答 6.2-3 What is the effect of calling Max-Heapify(A, i) when the element A[i] is larger than its children? algorithms_53765301.odp 習題6.2-3 algorithms sort counting sort F9506029 Thu Feb 26 17:00:52 2009 證明 8.2-3 Suppose that the for loop header in line 9 of the Counting-Sort procedure is rewritten as 9 for j ← 1 to length[A] Show that the algorithm still works properly. Is the modified algorithm stable? algorithms_53763930.pdf 習題9.2-3 algorithms sort selection F9506011 Thu Feb 26 16:57:38 2009 設計演算法 9.3-1 In the algorithm Select, the input elements are divided into groups of 5. Will the algorithm work in linear time if they are divided into groups of 7? Argue that Select does not run in linear time if groups of 3 are used. algorithms_53763736.odp 習題9.3-1 algorithms sort F9506229 Thu Feb 26 16:53:20 2009 證明 8.1-4 You are given a sequence of n elements to sort. The input sequence consists of n/k subsequences, each containing k elements. The elements in a given subsequence are all smaller than the elements in the succeeding subsequence and larger than the elements in the preceding subsequence. Thus, all that is needed to sort the whole sequence of length n is to sort the k elements in each of the n/k subsequences. Show an Ω(n lg k) lower bound on the number of comparisons needed to solve this variant of the sorting problem. (Hint: It is not rigorous to simply combine the lower bounds for the individual subsequences.) algorithms_53763478.pdf 習題8.1-4 algorithms sort heap sort F9506035 Thu Feb 26 16:49:19 2009 time complexity 6.2-6 Show that the worst-case running time of Max- Heapify on a heap of size n is Ω(lg n). algorithms_53763237.pdf 習題6.2-6 algorithms sort heap sort 張文龍 Thu Feb 26 16:46:15 2009 基本性質 6.1-4 Where in a max-heap might the smallest element reside, assuming that all elements are distinct? algorithms_53763053.odp 習題6.1-4 algorithms sort heap sort 王立恩 Thu Feb 26 16:41:24 2009 修改演算法 6.2-5 The code for Max-Heapify is quite efficient in terms of constant factors, except possibly for the recursive call in line 10, which might cause some compilers to produce inefficient code. Write an efficient Max-Heapify that uses an iterative contro construct (a loop) instead of recursion. algorithms_53762762.odt 習題6.2-5 algorithms sorting heapsort f9506021 Thu Feb 26 6:27:57 2009 分析演算法 6.4-3 What is the running time of heapsort on an array A of length n that is already sorted in increasing order? What about decreasing order? algorithms_53725955.odp 習題 6.4-3 algorithms sorting bucket-sort time complexity f9506015 Thu Feb 26 6:21:19 2009 修改演算法 8.4-2 What is the worst-case running time for the bucket-sort algorithm? What simple change to the algorithm preserves its linear expected running time and makes its worst-case running time O(nlogn)? algorithms_53725557.odp 習題 8.4-2 algorithms data structure heap 曾一平 Thu Feb 26 6:16:22 2009 執行演算法 6.5-2 Illustrate the operation of MAX-HEAP-INSERT(A, 10) on the heap A={15, 13, 9, 5, 12, 8, 7, 4, 0, 6, 2, 1}. Use the heap of Fig6,5 as a model for the HEAP-INCREASE-KEY call. algorithms_53725260.odp 習題 6.5-2 algorithms sorting Quicksort spring Fri Apr 25 11:20:55 2008 翻譯 請寫出下列英文的中文大意 The running time of quicksort depends on whether the partition is balanced or unbalanced, and this in turn depends on which elements are used for partitioning. If the partitioning is balanced, the algorithm runs asymptotically as fast as merge sort. If the partitioning is unbalanced, however, it can run asymptotically as slowly as insertion sort. algorithms_27218733.odp 平常測驗一 algorithms sorting counting sort spring Fri Apr 25 11:19:28 2008 執行演算法 Perform the operation of Counting-Sort on the array A = 6, 5, 2, 3, 2, 4, 4, 2, 1, 7, 3.要寫下陣列 C 的三個主要內容與最後陣列 B 的內容。 algorithms_27218646.odp 平常測驗一 algorithms sorting stable in place average case spring Fri Apr 25 11:18:10 2008 計算 Fill the following table. algorithms_27218568.odp 平常測驗一 algorithms sorting Quicksort Partition spring Fri Apr 25 11:15:53 2008 執行演算法 Perform the operation of Partition on the array A = 〈13, 19, 9, 5, 12, 8, 7, 4, 11, 2, 6,10〉. algorithms_27218431.odp 平常測驗一 algorithms sorting heap sort heap spring Fri Apr 25 11:14:22 2008 執行演算法 請用 heap sort 的方式來將 〈13, 2, 25, 7, 17, 20〉 作遞減排序 a)請用 min-heapify 將 heap 建出來。寫出調整每一個元素後的情形。 b)寫出建完 heap 後的排序過程，寫出搬走每個元素、調整完後的結果。 algorithms_27218340.odp 平常測驗一 algorithms function Master Theorem spring Fri Apr 25 11:12:02 2008 計算 Give asymptotic upper and lower bounds for T(n) in each of the following recurrences. a. T(n) = T(n-1) + 1/n. b. T(n) = T(n-1) + lg n. c. T(n) = 7T(n/2) + n2. d. T(n) = 16T(n/4) + n2. e. T(n) = 7T(n/3) + n2. f. T(n) = T(n-1) + n. algorithms_27218200.odp 平常測驗一 algorithms function spring Fri Apr 25 11:08:38 2008 計算 Rank the following functions by order of growth; that is, find an arrangement g1, g2, ..., g15 of the functions satisfying g1 = (g2), g2 = (g3), ..., g14 = (g15). n2, n!, (lg n)!, n3, lg2n, lg(n!), 22n, 2nn, n2n, nlg lgn, (lg n)lg n, 4lg n, 2n, n lg n, 22n+1 algorithms_27217996.odp 平常測驗一 algorithms sorting selection sort insertion sort spring Fri Apr 25 11:06:10 2008 執行演算法 請分別使用 selection sorting 、insertion sort的方式對 〈35, 32, 24, 33, 18, 11, 15〉作遞增排序；寫下每一個元素被排好後的情形。 algorithms_27217848.odp 平常測驗一 algorithms time complexity heap Theta Big O spring Fri Apr 25 11:04:39 2008 是非題 是非題 f(n) + g(n) = (max(f(n), g(n))). f(n) = O(g(n) g(n) = O(f(n)). An array that is sorted in non-decreasing order is a min-heap. The sequence 〈23, 17, 14, 6, 13, 10, 11, 5, 4, 12〉 is a max-heap. The time complexity of the best case of heap sort is O(n). algorithms_27217757.odp 平常測驗一 algorithms sorting counting sort spring Fri Apr 25 10:57:12 2008 翻譯 請寫出下列英文的中文大意 The basic idea of counting sort is to determine, for each input element x, the number of elements less than x. This information can be used to place element x directly into its position in the output array. For example, if there are 17 elements less than x, then x belongs in output position 18. algorithms_27217310.odp 平常測驗一 algorithms sorting radix sort spring Fri Apr 25 10:55:37 2008 執行演算法 Sort the following number in descending order with Radix Sort: 3852, 4621, 1357, 2489, 8543, 5781, 8799, 1076, 4893, 3651. algorithms_27217215.odp 平常測驗一 algorithms sorting stable in place worst case spring Fri Apr 25 10:54:00 2008 基本性質 Fill the following table. algorithms_27217118.odp 平常測驗一 algorithms sorting Quicksort Partition spring Fri Apr 25 10:51:35 2008 執行演算法 Perform the operation of Partition on the array A = 〈10, 19, 9, 5, 12, 8, 7, 4, 11, 2, 6,13〉. algorithms_27216973.odp 平常測驗一 algorithms sorting heap heap sort spring Fri Apr 25 10:44:20 2008 執行演算法 請用 heap sort 的方式來將 〈13, 2, 3, 25, 7, 17, 8〉 作遞增排序 a)請用 max-heapify 將 heap 建出來。寫出調整每一個元素後的情形。 b)寫出建完 heap 後的排序過程，寫出搬走每個元素、調整完後的結果。 algorithms_27216538.odp 平常測驗一 algorithms function Master Theorem spring Fri Apr 25 10:40:57 2008 計算 Give asymptotic upper and lower bounds for T(n) in each of the following recurrences. a. T(n) = 2T(n/4) + n1/2 b. T(n) = T(n-1) + lg n c. T(n) = 7T(n/2) + n2 d. T(n) = T(n1/2) + 1 e. T(n) = 4T(n/2) + n3 f. T(n) = T(n-1) + n algorithms_27216335.odp 平常測驗一 algorithms function time complexity spring Fri Apr 25 10:39:20 2008 計算 Rank the following functions by order of growth; that is, find an arrangement g1, g2, ..., g15 of the functions satisfying g1 = O(g2), g2 = O(g3), ..., g14 = O(g15). lg(lg*n), n2n, n!, (lg n)!, (3/2)n, lg2n, 22n, lg*n, 2nn, nlg lgn,(lg n)lg n, (n+1)!, lg*(lg n), 2n, 22n+1 algorithms_27216238.odp 平常測驗一 algorithms sorting heap spring Fri Apr 25 10:36:59 2008 設計演算法 6.5-8 Give an O(n lg k)-time algorithm to merge k sorted lists into one sorted list, where n is the total number of elements in all the input lists. (Hint: Use a min-heap for k-way merging.) algorithms_27216097.odp 習題6.5-8 algorithms sorting selection sort insertion sort spring Fri Apr 25 10:33:34 2008 執行演算法 請分別使用 selection sorting 、insertion sort的方式對 〈35, 32, 24, 33, 18, 11, 15〉作遞減排序；寫下每一個元素被排好後的情形。 algorithms_27215892.odp 平常測驗一 algorithms time complexity Big O heap sorting spring Fri Apr 25 10:31:26 2008 是非題 是非題 f(n) + g(n) = (min(f(n), g(n))). f(n) = O(g(n)) ==> 2f(n) = O(2g(n)). The height of a heap with 33 elements is 4. The sequence 〈3, 7, 4, 6, 13, 10, 11, 15, 14, 16〉 is a min-heap. Any comparison sort algorithm requires Ω(n lg n) comparisons in the worst case. algorithms_27215764.odp 平常測驗一 algorithms function Master Theorem spring Fri Apr 25 8:41:13 2008 計算 4.3-1 Use the master method to give tight asymptotic bounds for the following recurrences. a. T(n) = 4T(n/2) + n. b. T(n) = 4T(n/2) + n2. c. T(n) = 4T(n/2) + n3. algorithms_27209151.odp 習題4.3-1 algorithms function Big O Theta Big Omega spring Fri Apr 25 8:39:17 2008 證明 Problem 3-4 Asymptotic notation properties Let f(n) and g(n) be asymptotically positive functions. Prove or disprove each of the following conjectures. a. f(n) = O(g(n)) implies g(n) = O(f(n)). b. f(n) + g(n) = Θ(min(f(n), g(n))). c. f(n) = O(g(n)) implies lg(f(n)) = O(lg(g(n))), where lg(g(n)) ≥ 1 and f(n) ≥ 1 for all sufficiently large n. d. f(n) = O(g(n)) implies 2f(n) = O(2g(n)). e. f(n) = O((f(n))2). f. f(n) = O(g(n)) implies g(n) = Ω(f(n)) g. f(n) = Θ(f(n/2)) h. f(n) + o(f(n)) = Θ(f(n)). algorithms_27209035.odp 習題 Problem 3-4 algorithms function spring Fri Apr 25 8:35:05 2008 計算 Problem 3-3 Ordering by asymptotic growth rates algorithms_27208783.odp 習題 Problem 3-3 algorithms time complexity spring Fri Apr 25 8:31:19 2008 證明 3.1-7 Prove that o(g(n)) ∩ ω(g(n)) = Ø. algorithms_27208557.odp 習題3.1-7 algorithms sorting time complexity spring Fri Apr 25 8:29:07 2008 設計演算法 2.3-7 Describe a (n lg n)-time algorithm that, given a set S of n integers and another integer x, determines whether or not there exist two elements in S whose sum is exactly x. algorithms_27208424.odp 習題2.3-7 algorithms sorting selection sort spring Fri Apr 25 8:27:14 2008 設計演算法 2.2-2 Consider sorting n numbers sotred in array A by first finding the smallest element of A and exchanging it with the element in A[1]. Then find the second smallest element of A, and exchange it with A[2]. Continue in this manner for the first n-1 elements of A. Write pseudocode for this algorithm, which is known as selection sort. What loop invariant does this algorithm maintain? Why does it need to run for only the first n – 1 elements, rather than for all n elements? Give the best-case and worst case running times of selection sort in -notation. algorithms_27208312.odp 習題2.2-2 algorithms time complexity merge sort insertion sort spring Fri Apr 25 8:24:18 2008 計算 1.2-2 Suppose we are comparing implementations of insertion sort and merge sort on the same machine. For inputs of size n, insertion sort runs in 8n2 steps, while merge sort runs in 64 n log2n steps. For which values of n does insertion sort beat merge sort? algorithms_27208136.odp 習題1.2-2 algorithms data structure linked list spring Tue Apr 22 8:14:59 2008 翻譯 請寫出下列英文的中文大意 A linked list is a data structure in which the objects are arranged in a linear order. Unlike an array, though, in which the linear order is determined by the array indices, the order in a linked list is determined by a pointer in each object. Linked lists provide a simple, flexible representation for dynamic sets. algorithms_26948377.odp 期中考 algorithms selection randomized algorithms spring Tue Apr 22 8:02:25 2008 執行演算法 Suppose we use Randomized-Select to select the minimum element of the array A = 〈3, 2, 9, 0, 7, 5, 4, 8, 6, 1〉. Describe a sequence of partitions that results in a worst-case performance of Randomized-Select. algorithms_26947623.odp 習題 9.2-4 algorithms sorting counting sort stable in place spring Tue Apr 22 7:58:00 2008 設計演算法 Suppose that we have an array of n data records to sort and that the key of each record has the value 0 or 1. An algorithm for sorting such a set of records might possess some subset of the following three desirable characteristics: 1. The algorithm runs in O(n) time. 2. The algorithm is stable. 3. The algorithm sorts in place. a. Give an algorithm that satisfies criteria 1 and 2 above. b. Give an algorithm that satisfies criteria 1 and 3 above. c. Give an algorithm that satisfies criteria 2 and 3 above. algorithms_26947358.odp 習題 problem 8-2 algorithms time complexity function spring Tue Apr 22 7:55:21 2008 證明 Let f(n) and g(n) be asymptotically positive functions. Prove or disprove each of the following conjectures. a) f(n)=O(g(n)) implies g(n) = O(f(n)). b) f(n)=O(g(n)) implies 2f(n) = O(2g(n)). c) f(n) = Θ(f(n/2)). algorithms_26947199.odp 期中考 algorithms time complexity recursive function master theorem spring Tue Apr 22 7:53:26 2008 計算 Give asymptotic upper and lower bounds for T(n) in each of the following recurrences. a. T(n) = T(n-1) + 1/n. b. T(n) = T(n/2)+T(n/4)+T(n/8) + n. c. T(n) = 5T(n/2) + n2. d. T(n) = 27T(n/3) + n3. e. T(n) = 2T(n-1) + 1. f. T(n) = T(n/2) + n½. algorithms_26947084.odp 期中考 algorithms heap priority queue spring Tue Apr 22 7:51:20 2008 執行演算法 Perform the operation of Max-Heap-Insert(A, 20) on the heap A = 〈15, 13, 9, 5, 12, 8, 7, 4, 0, 6, 2, 1〉. algorithms_26946958.odp 期中考 algorithms selection sorting spring Tue Apr 22 7:47:56 2008 設計演算法 Suppose that you have a \"black-box\" worst-case linear-time median subroutine. Give a simple, linear-time algorithm that solves the selection problem for an arbitrary order statistic. algorithms_26946754.odp 習題9.3-5 algorithms sorting selection median spring Tue Apr 22 7:41:51 2008 分析演算法 Given a set of n numbers, we wish to find the i largest in sorted order using a comparison-based algorithm. Find the algorithm that implements each of the following methods with the best asymptotic worst-case running time, and analyze the running times of the algorithms in terms of n and i. a. Sort the numbers, and list the i largest. b. Build a max-priority queue from the numbers, and call Extract-Max i times. c. Use an order-statistic algorithm fo find the ith largest number, partition around that number, and sort the i largest numbers. algorithms_26946389.odp 習題 problem 9-1 algorithms time complexity data structure sorting spring Tue Apr 22 7:38:00 2008 是非題 是非題 n0.001 + lg1000 n = (lg1000n). 1.001n + n1000 = O(n1000). The time complexity of worst case of quicksort is (n lg n). The time complexity of the best case of insertion sort is O(n). A stack is the data structure based on the principle of “First In First Out”. algorithms_26946158.odp 期中考 algorithms all-pairs shortest paths spring Tue Dec 25 12:50:31 2007 翻譯 請寫出下列英文的中文大意 We can solve an all-pairs shortest-paths problem by running a single-source shortest-paths algorithm |V| times, once for each vertex as the source. If all edge weights are nonnegative, we can use Dijkstra\'s algorithm. If we use the linear-array implementation of the min-priority queue, the running time is O(V3+VE) = O(V3). The binary min-heap implementation of the min-priority queue yields a running time of O(VE lg V), which is an improvement if the graph is sparse. Alternatively, we can implement the min-priority queue with a Fibonacci heap, yielding a running time of O(V2 lg V + VE). algorithms_16683309.odp 期中考題 algorithms shortest paths Dijkstra\'s algorithm spring Tue Dec 25 12:47:43 2007 證明 Suppose that we are given a weighted, directed graph G = (V, E) in which edges that leave the source vertex s may have negative weights, all other edge weights are nonnegative, and there are no negative-weight cycles. Argue that Dijkstra\'s algorithm correctly finds shortest paths from s in this graph. algorithms_16683141.odp 期中考題 algorithms shortest paths tree spring Tue Dec 25 12:44:19 2007 設計演算法 The diameter of a tree T = (V, E) is given by that is, the diameter is the largest of all shortest-path distances in the tree. Given an efficient algorithm to compute the diameter of a tree, and analyze the running time of your algorithm. algorithms_16682937.odp 期中考題 algorithms shortest paths linear programming spring Tue Dec 25 12:42:16 2007 執行演算法 Find a feasible solution or determine that no feasible solution exists for the following system of difference constraints: x1 – x2 ≤ 1, x1 – x4 ≤ -4, x2 – x3 ≤ 2, x2 – x5 ≤ 7, x2 – x6 ≤ 5, x3 – x6 ≤ 10, x4 – x2 ≤ 2, x5 – x1 ≤ -1, x5 – x4 ≤ 3, x6 – x3 ≤ -8。 algorithms_16682814.odp 期中考題 algorithms shortest paths Johnson\'s algorithm spring Tue Dec 25 12:38:09 2007 執行演算法 Use Johnson\'s algorithm to find the shortest paths between all pairs of vertices in the following graph. Show the values of h and w\' computed by the algorithm. algorithms_16682567.odp 期中考題 algorithms shortest paths Floyd-Warshall spring Tue Dec 25 9:02:51 2007 執行演算法 Run the Floyd-Warshall algorithm on the following weighted, directed graph. Show the matrix D(k) that results for each iteration of the outer loop. algorithms_16669649.odp 期中考題 algorithms disjoint sets union and find spring Tue Dec 25 9:00:08 2007 執行演算法 0~12的數字，假設一開始每個數字都是一個集合，用union by rank與path compression作以下的運作，請畫出最後的結果。Union(0, 1), Union(2, 3), Union(6, 7), Union(0, 12), Union(8, 9), Union(10, 11), Union(0, 2), Union(8, 10), Union(0, 4), Union(4, 5), Find-set(6), Union(0, 8), Union(4, 6), Find-set(8)。 algorithms_16669486.odp 期中考題 algorithms shortest paths Bellman-Ford algorithm spring Tue Dec 25 8:58:41 2007 執行演算法 Run the Bellman-Ford algorithm on the following directed graph, using vertex z as the source. algorithms_16669399.odp 期中考題 algorithms topological sort directed acyclic graphs depth-first search 習題22.4-1 spring Wed Nov 21 6:36:33 2007 執行演算法 Show the ordering of vertices produced by TOPOLOGICAL-SORT when it is run on the following dag. algorithms_13723271.odp 期中考題 algorithms graphs depth-first search spring Mon Nov 5 18:03:32 2007 給反例 Give a counterexample to the conjecture that if there is a path from u to v in a directed graph G, and if d[u] ≤ d[v] in a depth-first search of G, then v is a descendant of u in the depth-first forest produced. algorithms_12382090.odp 習題22.3-7 algorithms shortest paths directed acyclic graph spring Mon Nov 5 17:58:56 2007 設計演算法 Give an efficient algorithm to count the total number of paths in a directed acyclic graph. Analyze your algorithm. algorithms_12381813.odp 習題24.2-4 algorithms all-pairs shortest paths Johnson\'s algorithm spring Mon Nov 5 17:56:04 2007 基本性質 Suppose that w(u, v) ≥ 0 for all edges (u, v) ∈ E. What is the relationship between the weight functions w and w\'? algorithms_12381642.odp 習題25.3-3 algorithms all-pairs shortest paths transitive closure spring Mon Nov 5 17:54:00 2007 設計演算法 Give an O(VE)-time algorithm for computing the transitive closure of a directed graph G(V, E). algorithms_12381518.odp 習題25.2-8 algorithms all-pairs shortest paths negative-weight cycle spring Mon Nov 5 17:52:06 2007 修改演算法 Modify FASTER-ALL-PAIRS-SHORTEST-PATHS so that it can detect the presence of a negative-weight cycle. algorithms_12381404.odp 習題25.1-9 algorithms shortest paths Bellman-Ford algorithm negative-weight cycle spring Mon Nov 5 17:49:14 2007 證明 Let G = (V, E) be a weighted, directed graph with source vertex s, and let G be initialized by INITIALIZE-SINGLE-SOURCE(G, s). Prove that if a sequence of relaxation steps sets π[s] to a non-NIL value, then G contains a negative-weight cycle. algorithms_12381232.odp 習題24.5-4 algorithms shortest paths linear programming spring Mon Nov 5 17:46:48 2007 執行演算法 Find a feasible solution or determine that no feasible solution exists for the following system of difference constraints: x1 – x2 ≤ 4, x1 – x5 ≤ 5, x2 – x4 ≤ -6, x3 – x2 ≤ 1, x4 – x1 ≤ 3, x4 – x3 ≤ 5, x4 – x5 ≤ 10, x5 – x3 ≤ -4, x5 – x4 ≤ -8. algorithms_12381086.odp 習題24.4-2 algorithms shortest paths Dijkstra\'s algorithm spring Mon Nov 5 17:45:16 2007 給反例 Give a simple example of a directed graph with negative-weight edges for which Dijkstra\'s algorithm produces incorrect answers. Why doesn\'t the proof of Theorem 24.6 go through when negative-weight edges are allowed? algorithms_12380994.odp 習題24.3-2 algorithms shortest paths Bellman-Ford algorithm spring Mon Nov 5 17:41:06 2007 執行演算法 Modify the Bellman-Ford algorithm so that it sets d[v] to -∞ for all vertices v for which there is a negative-weight cycle on some path from the source to v. algorithms_12380744.odp 習題24.1-4 algorithms minimum cost spanning tree Kruskal\'s algorithm spring Mon Nov 5 17:30:45 2007 分析演算法 Suppose that all edge weights in a graph are integers in the range from 1 to |V|. How fast can you make Kruskal\'s algorithm run? What if the edge weights are integers in the range from 1 to W for some constant W? algorithms_12380123.odp 習題23.2-4 algorithms minimum cost spanning tree light edge spring Mon Nov 5 17:26:44 2007 證明 Show that a graph has a unique minimum spanning tree if, for every cut of the graph, there is a unique light edge crossing the cut. Show that the converse is not true by giving a counterexample. algorithms_12379882.odp 習題23.1-6 algorithms graphs strongly connected components directed graph spring Mon Nov 5 17:19:35 2007 基本性質 How can the number of strongly connected components of a graph change if a new edge is added? algorithms_12379453.odp 習題22.5-1 algorithms graphs depth-first search cycle spring Mon Nov 5 17:16:58 2007 設計演算法 Give an algorithm that determines whether or not a given undirected graph G = (V, E) contains a cycle. Your algorithm should run in O(V) time, independent of |E|. algorithms_12379296.odp 習題22.4-3 algorithms graphs breadth-first search spring Mon Nov 5 17:10:56 2007 執行演算法 Show the d and π values that result from running breadth-first search on the directed graph of Figure 22.2(a), using vertex 3 as the source. algorithms_12378934.odp 習題22.2-1 algorithms disjoint sets union and find spring Mon Nov 5 17:09:01 2007 證明 Professor Dante reasons that because node ranks increase strictly along a path to the root, node levels must monotonically increase along the path. In other words, if rank(x) > 0 and p[x] is not a root, then level(x) ≤ level(p[x]). Is the professor correct? algorithms_12378819.odp 習題21.4-5 algorithms disjoint sets union and find spring Mon Nov 5 17:07:14 2007 設計演算法 Suggest a simple change to the Union procedure for the linked-list representation that removes the need to keep the tail pointer to the last object in each list. Whether or not the weighted-union heuristic is used, your change should not change the asymptotic running time of the Union procedure. (Hint: Rather than appending one list to another, splice them together.) algorithms_12378712.odp 習題21.2-5 algorithms shortest paths single source shortest paths directed acyclic graphs topological sort spring Wed Oct 24 14:18:29 2007 執行演算法 Run DAG-SHORTEST-PATHS on the directed graph of Figure 24.5, using vertex r as the source. algorithms_11331787.odp 習題24.2-1 algorithms shortest paths single source shortest paths Bellman-Ford negative edge spring Wed Oct 24 14:14:54 2007 執行演算法 Run the Bellman-Ford algorithm on the directed graph of Figure 24.4, using vertex z as the source. algorithms_11331572.odp 習題24.1-1 algorithms minimum spanning tree Prim\'s algorithm spring Wed Oct 24 6:21:34 2007 計算 Is the Fibonacci-heap implementation of Prim\'s algorithm asymptotically faster than the binary-heap implementation for a sparse graph G = (V, E), where |E| = Θ(V)? What about for a dense graph, where |E| = Θ(V2)? How must |E| and |V| be related for the Fibonacci-heap implementation to be asymptotically faster than the binary-heap implementation? algorithms_11303172.odp 隨堂測驗 algorithms minimum spanning tree spring Wed Oct 24 6:19:17 2007 證明 Let (u, v) be a minimum-weight edge in a graph G. Show that (u, v) belongs to some minimum spanning tree to G. algorithms_11303035.odp 隨堂測驗 algorithms breadth-first search bipartite graph spring Wed Oct 3 17:35:26 2007 設計演算法 There are two types of professional wrestlers(摔角選手): \"good guys\" and \"bad guys\". Between any pair of professional wrestlers, there may or may not be a rivalry(競賽). Suppose we have n professional wrestlers and we have a list of r pairs of wrestlers for which there are rivalries. Given an O(n+r)-time algorithm that determines whether it is possible to designate some of the wrestlers as good guys and the remainder as bad guys such that each rivalry is between a good guy and a bad guy. If it is possible to perform such a designation, your algorithm should produce it. algorithms_9529204.odp 習題22.2-6 algorithms breadth-first search spring Wed Oct 3 17:25:59 2007 執行演算法 Show the d and π values that result from running breadth-first search on the undirected graph of Figure 22.3, using vertex u as the source. algorithms_9528637.odp 習題22.2-2 algorithms graphs adjacency list adjacency matrix square of a graph spring Wed Oct 3 16:09:44 2007 基本性質 The square of a directed graph G = (V, E) is the graph G2 = (V, E2) such that (u, w) ∈ E2 if and only if for some v ∈ V, both (u, v) ∈ E and (v, w) ∈ E. That is, G2 contains an edge between u and w whenever G contains a path with exactly two edges between u and w. Describe efficient algorithms for computing G2 from G for both the adjacency-list and adjacency-matrix representations of G. Analyze the running times of your algorithms. algorithms_9524062.odp 習題22.1-5 algorithms graphs 基本性質 multigraph spring Wed Oct 3 15:44:43 2007 基本性質 Given an adjacency-list representation of a multigraph G = (V, E), describe an O(V + E)-time algorithm to compute the adjacency-list representation of the \"equivalent\" undirected graph G\' = (V, E\'), where E\' consists of the edges in E with all multiple edges between two vertices replaced by a single edge and with all self-loops removed. algorithms_9522561.odp 習題22.1-4 algorithms graphs 基本性質 indegree outdegree spring Wed Oct 3 15:35:16 2007 基本性質 Given an adjacency-list representation of a directed graph, how long does it take to compute the out-degree of every vertex? How long does it take to compute the in-degrees? algorithms_9521994.odp 習題22.1-1 algorithms graphs breadth-fire search spring Wed Oct 3 12:42:37 2007 執行演算法 Show the d and π values that result from running breadth-first search on the following directed graph, using vertex 3 as the source. algorithms_9511635.odp 習題22.2-1 algorithms graphs sinker spring Wed Oct 3 12:40:26 2007 設計演算法 When an adjacency-matrix representation is used, most graph algorithms require time Ω(V2), but there are some exceptions. Show that determining whether a directed graph G contains a universal sink – a vertex with in-degree |V| - 1 and out-degree 0 – can be determined in time O(V), given an adjacency matrix for G. algorithms_9511504.odp 習題22.1-6 algorithms disjoint sets union and find 習題 spring Wed Sep 26 13:47:36 2007 證明 Show that any sequence of m Make-set, Find-set, and Union operations, where all the Union operations appear before any of the Find-set operations, takes only O(m) time if both path compression and union by rank are used. What happens in the same situation if only the path-compression heuristic is used? algorithms_8910734.odp 習題21.3-4 algorithms disjoint sets union and find spring Wed Sep 26 13:43:00 2007 執行演算法 0~11的數字，假設一開始每個數字都是一個集合，用union by rank與path compression作以下的運作，請畫出最後的結果。Union(0, 1), Union(2, 3), Union(6, 7), Union(8, 9), Union(10, 11), Union(0, 2), Union(8, 10), Union(0, 4), Union(4, 5), Find-set(6), Union(0, 8), Union(4, 6), Find-set(8)。 algorithms_8910458.odp algorithms graphs tree diameter spring Tue Sep 25 16:21:27 2007 設計演算法 Given an efficient algorithm to compute the diameter of a tree, and analyze the running time of your algorithm. algorithms_8833565.odp 習題 22.2-7 algorithms data structure function recursive spring Fri Aug 24 21:44:51 2007 程式設計 The Fibonacci numbers are defined as: f0= 0, f1= 1, and fi= fi-1+ fi-2for i> 1. Write a recursive function to compute fi with C++ language. algorithms_6088169.odp algorithms greedy algorithm task-scheduling problem spring Tue Jul 24 17:29:26 2007 執行演算法 Solve the instance of the scheduling problem given in the follows. algorithms_3394444.odp algorithms greedy algorithm Huffman code spring Tue Jul 24 17:21:50 2007 執行演算法 What is an optimal Huffman code for the following set of frequencies? a:1 b:5 c:7 d:10 e:15 f:23 g:31 h:40 。 algorithms_3393988.odp algorithms greedy algorithm knapsack 0-1 knapsack spring Tue Jul 24 17:08:47 2007 執行演算法 下表中代表每個物品的重點(wi)與價值(pi)，請問袋子最多可裝15公斤時，所能裝的物品價值最高為何？請求knapsack 與 0-1 knapsack 的答案。 algorithms_3393205.odp algorithms greedy algorithm activity selection spring Tue Jul 24 16:52:45 2007 執行演算法 找出下表中所能參加最多的 activities。 algorithms_3392243.odp algorithms dynamic programming longest common subsequence spring Tue Jul 24 16:18:47 2007 執行演算法 Determine an LCS of 〈1,0,0,1,0,1,0,1〉 and 〈0, 1, 0, 1, 1, 0, 1, 1, 0〉. algorithms_3390205.odp algorithms dynamic programming Matrix-chain multiplication spring Tue Jul 24 8:17:53 2007 執行演算法 Find an optimal parenthesization of a matrix-chain product whose sequence of dimensions is 〈5, 3, 12, 5, 6〉. algorithms_3361351.odp algorithms dynamic programming Matrix-chain multiplication spring Tue Jul 24 7:52:31 2007 執行演算法 Find an optimal parenthesization of a matrix-chain product whose sequence of dimensions is 〈5, 10, 3, 50, 6〉. algorithms_3359829.odp algorithms dynamic programming spring Tue Jul 24 7:34:31 2007 執行演算法 找出下列問題的最短路徑。 algorithms_3358749.odp algorithms dynamic programming spring Tue Jul 24 7:15:00 2007 執行演算法 找出下列問題的最短路徑。 algorithms_3357578.odp algorithms order-statistic tree data structure spring Mon Jul 23 7:40:50 2007 設計演算法 Show how to use an order-statistic tree to count the number of inversions (see Problem 2-4) in an array of size n in time O(n lg n). algorithms_3272728.odp algorithms red black tree data structure spring Mon Jul 23 7:32:04 2007 執行運算 Show the red-black trees that result after successively inserting the keys 41, 38, 31, 12, 19, 8 into an initially empty red-black tree. And then show the red-black trees that result from the successive deletion of the keys in the order 8, 12, 19, 31, 38, 41. algorithms_3272202.odp algorithms binary search tree red black tree spring Sun Jul 22 20:16:43 2007 計算 Describe a red-black tree on n keys that realizes the largest possible ratio of red internal nodes to black internal nodes. What is this ratio? What tree has the smallest possible ratio, and what is the ratio? algorithms_3231681.odp 習題13.1-7 algorithms red black tree spring Sun Jul 22 20:12:56 2007 計算 What is the largest possible number of internal nodes in a red-black tree with black-height k? What is the smallest possible number? algorithms_3231454.odp 習題13.1-6 algorithms binary search tree sorting spring Sun Jul 22 8:08:30 2007 分析演算法 We can sort a given set of n numbers by first building a binary search tree containing these numbers(using TREE_INSERT repreatedly to insert the numbers one by one) and then printing the numbers by an inorder tree walk. What are the worst-case and best-case running times for this sorting algorithm? algorithms_3187988.odp 習題12.3-3 algorithms binary search tree spring Sun Jul 22 8:00:59 2007 選擇題 Suppose that we have numbers between 1 and 1000 in a binary search tree and want to search for the number 363. Which of the following sequences could not be the sequence of nodes examined? a. 2, 252, 401, 398, 330, 344, 397, 363. b. 924, 220, 911, 244, 898, 258, 362, 363. c. 925, 202, 911, 240, 912, 245, 363. d. 2, 399, 387, 219, 266, 382, 381, 278, 363. e. 935, 278, 347, 621, 299, 392, 358, 363. algorithms_3187537.odp 習題12.2-1 algorithms binary search tree spring Sat Jul 21 11:43:17 2007 畫圖 For the set of keys {1, 4, 5, 10, 16, 17, 21}, draw binary search trees of height 2, 3, 4, 5, and 6. algorithms_3114475.odp 習題12.1-1 algorithms hashing functions spring Sat Jul 21 11:35:28 2007 計算 Consider inserting the keys 10, 22, 31, 4, 15, 28, 17, 88, 59 into a hash table of length m = 11 using open addressing with the auxiliary hash function h\'(k) = k mod m. Illustrate the result of inserting these keys using linear probing, using quadratic probing with c1 = 1 and c2 = 3, and using double hashing with h2(k) = 1 + (k mod (m-1)). algorithms_3114006.odp algorithms data structure tree spring Sat Jul 21 11:21:28 2007 畫圖 Draw the binary tree rooted at index 6 that is represented by the follow fields. algorithms_3113166.odp algorithms data structure stack queue spring Sat Jul 21 11:15:45 2007 設計資料結構 Show how to implement a queue using two stacks. Analyze the running time of the queue operations. algorithms_3112823.odp 習題10.1-6 algorithms selection randomized algorithms spring Sat Jul 21 11:08:17 2007 執行演算法 Suppose we use Randomized-Select to select the minimum element of the array A = 〈3, 2, 9, 0, 7, 5, 4, 8, 6, 1〉. Describe a sequence of partitions that results in a worst-case performance of Randomized-Select. algorithms_3112375.odp algorithms quick sort randomized algorithms spring Sat Jul 21 10:57:28 2007 分析演算法 During the running of the procedure Randomized-Quicksort, how many calls are made to the random-number generator Random in the worst case? How about in the best case? Give your answer in terms of Θ-notation. algorithms_3111725.odp 習題7.3-2 algorithms quick sort spring Sat Jul 21 10:41:23 2007 修改演算法 How would you modify Quicksort to sort into nonincreasing order? algorithms_3110761.odp 習題7.1-4 algorithms quick sort time complexity spring Sat Jul 21 10:38:03 2007 簡答 What is the time complexity of Quicksort when the array A contains distinct elements and is sorted in decreasing order ? algorithms_3110561.odp algorithms data structure heap spring Sat Jul 21 10:32:25 2007 計算 令 H 是一個 48 個元素的 heap，請問 H 中有幾個高度為 3 的 nodes？ algorithms_3110223.odp algorithms data structure heap spring Sat Jul 21 10:17:03 2007 執行演算法 Perform the operation of Build-Max-Heap on the array A = 〈5, 3, 17, 10, 84, 19, 6, 22, 9〉. algorithms_3109301.odp 習題6.3-1 algorithms data structure heap spring Sat Jul 21 10:08:00 2007 執行演算法 Perform the operation of Max-Heapify(A, 3) on the array A = 〈27, 17, 3, 16, 13, 10, 1, 5, 7, 12, 4, 8, 9, 0〉. algorithms_3108758.odp 習題6.2-1 algorithms data structure heap spring Sat Jul 21 10:01:20 2007 計算 What are the minimum and maximum numbers of elements in a heap of height h? algorithms_3108358.odp 習題6.1-1 algorithms data structure heap spring Sat Jul 21 9:15:54 2007 簡答 Is the sequence 〈23, 17, 14, 6, 13, 10, 1, 5, 7, 12〉 a max-heap? algorithms_3105632.odp algorithms data structure heap spring Sat Jul 21 9:07:47 2007 簡答 Is an array that is in sorted order a min-heap? algorithms_3105145.odp 習題6.1-5 algorithms data structure heap spring Sat Jul 21 9:03:58 2007 簡答 Where in a max-heap might the smallest element reside, assuming that all elements are distinct? algorithms_3104915.odp algorithms function recursive master theorem spring Sat Jul 21 8:59:57 2007 計算 Give asymptotic upper and lower bounds for T(n) in each of the following recurrences. Assume that T(n) is constant for n ≤ 2. A.T(n) = 2T(n/2) + n2. B.T(n) = 16T(n/4) + n2. C.T(n) = 3T(n/2) + n lg n. algorithms_3104675.odp algorithms function recursive spring Sat Jul 21 8:49:32 2007 計算 Solve the recurrence T(n) = 2T(n1/2) + 1 by making a change of variables. We can assume that T(1) = θ(1). algorithms_3104050.odp algorithms function introduction spring Sat Jul 21 8:39:37 2007 證明 Show that if f(n) and g(n) are monotonically increasing functions, then so are the functions f(g(n)). algorithms_3103455.odp algorithms function introduction spring Sat Jul 21 8:34:51 2007 證明 Show that if f(n) and g(n) are monotonically increasing functions, then so are the functions f(n) + g(n). algorithms_3103169.odp algorithms Getting Started inversion spring Thu Jul 12 11:36:37 2007 基本定義 List the inversions of the array 〈3, 6, 8, 1, 5〉. algorithms_2336475.odp