Fancy Mouse
- -|||

文章分类 -  CLRS

Chapter 15 Exercises and Problems
摘要:Exercises 15.5-4 Knuth has shown that there are always roots of optimal subtrees such that root[i,j-1] root[i+1,j], then root[i+1,j](in T[i,j]) must appear in the root[i,j]'s left subtree. Since i+1's... 阅读全文
posted @ 2008-04-29 17:28 Fancy Mouse 阅读(1484) 评论(1) 推荐(0)
Chapter 14 Exercises
摘要:Exercises 14.2-2 Can the black-heights of nodes in a red-black tree be maintained as fields in the nodes of the tree without affecting the asymptotic performance of any of the red-black tree operation... 阅读全文
posted @ 2008-04-29 17:17 Fancy Mouse 阅读(646) 评论(0) 推荐(0)
Chapter 13 Exercises
摘要:We use the following expression S(T) to show a tree T: if T is null, then S(T) is a null string if T contains only a root node, S(T) = root otherwise, let L and R are T's left and right subtrees, resp... 阅读全文
posted @ 2008-04-22 01:01 Fancy Mouse 阅读(1725) 评论(0) 推荐(0)
Chapter 12 Exercises and Problems
摘要:Exercises 12.1-3 Give a nonrecursive algorithm that performs an inorder tree walk. Here I give a solution that uses no stack but assumes that two pointers can be tested for equality. InorderTraverse(T... 阅读全文
posted @ 2008-02-16 11:27 Fancy Mouse 阅读(1542) 评论(0) 推荐(0)
Chapter 11 Exercises and Problems
摘要:Exercises 11.2-3 Professor Marley hypothesizes that substantial performance gains can be obtained if we modify the chaining scheme so that each list is kept in sorted order. How does the professor's m... 阅读全文
posted @ 2008-02-15 13:39 Fancy Mouse 阅读(2473) 评论(0) 推荐(0)
Chapter 10 Exercises
摘要:Exercises 10.1-7 Show how to implement a queue using two stacks. Analyze the running time of the queue operations. The amortized time is still O(1) each operation. DATA_TYPE Enqueue(DATA_TYPE data) ..... 阅读全文
posted @ 2008-01-28 22:47 Fancy Mouse 阅读(860) 评论(0) 推荐(0)
Chapter 9 Exercises and Problems
摘要:Exercises 9.3-6 The k-th quantiles of an n-element set are the k-1 order statistics that divide the sorted set into k equal-sized sets (to within 1). Give an O(nlogk)-time algorithm to list the k-th q... 阅读全文
posted @ 2008-01-27 16:50 Fancy Mouse 阅读(490) 评论(0) 推荐(0)
Chapter 8 Exercises and Problems
摘要:Exercises 8.1-3 Show that there is no comparison sort whose running time is linear for at least half of the n! inputs of length n. What about a fraction of 1/n of the inputs of length n? What about a ... 阅读全文
posted @ 2008-01-24 20:12 Fancy Mouse 阅读(4528) 评论(1) 推荐(0)
Chapter 7 Problems
摘要:Problems 7-3 Stooge sort Professors Howard, Fine, and Howard have proposed the following "elegant" sorting algorithm: STOOGE-SORT(A,i,j) 1 if A[i] > A[j] 2 then exchange A[i] A[j] 3 if i+1 >= j 4 the... 阅读全文
posted @ 2008-01-22 22:07 Fancy Mouse 阅读(614) 评论(0) 推荐(0)
Chapter 6 Exercises and Problems
摘要:Exercises 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? See 6.4-5 6.4-5 Show that when all elements are... 阅读全文
posted @ 2008-01-22 19:06 Fancy Mouse 阅读(924) 评论(0) 推荐(0)
Chapter 5 Exercises
摘要:Exercises 5.2-4 Given a permutation A, What is the expected number of indices i such that A[i] = i? The answer is amazingly a constant, 1. Lemma 5.1 The probablity of the permutation that no number is... 阅读全文
posted @ 2008-01-10 20:54 Fancy Mouse 阅读(480) 评论(0) 推荐(0)
Chapter 4, FAQ about Master Theorm, exercises and problems
摘要:FAQ about the Master theorem Q1: Why in case 1, f(n) must be polynomially smaller than n^log(b,a)? Recall the lemma proved in the proof of the master theorem i.e. for T(n) = a*T(n/b) + f(n) T(n) = Θ(n... 阅读全文
posted @ 2008-01-10 16:24 Fancy Mouse 阅读(3831) 评论(11) 推荐(0)
Chapter 3 Exercises and Problems
摘要:Exercises 3.1-4 Is 2^(n+1) = O(2^n)? Is 2^2n = O(2^n)? Yes. No. 3.1-7 Prove that o(g(n)) ∩ ω(g(n)) is the empty set. Assuming that there is a function f(n) ∈o(g(n)) ∩ ω(g(n)) then f(n) ∈o(g(n)) ,f(n)... 阅读全文
posted @ 2007-12-25 16:01 Fancy Mouse 阅读(2570) 评论(2) 推荐(0)
Chapter 2 Exercises and Problems
摘要:Exercises 2.2-4 How can we modify almost any algorithm to have a good best-case running time? CHEAT. Is there any OIer who can not cheat? That's O(1). 2.3-6 Can we use a binary search instead to impr... 阅读全文
posted @ 2007-12-24 21:02 Fancy Mouse 阅读(521) 评论(0) 推荐(0)