recurrence

Complex Combinatorial Conditions on Dynamic Programming

▼魔方 西西 提交于 2019-12-08 03:31:01
问题 I am exploring how a Dynamic Programming design approach relates to the underlying combinatorial properties of problems. For this, I am looking at the canonical instance of the coin change problem : Let S = [d_1, d_2, ..., d_m] and n > 0 be a requested amount. In how many ways can we add up to n using nothing but the elements in S ? If we follow a Dynamic Programming approach to design an algorithm for this problem that would allow for a solution with polynomial complexity, we would start by

recurrence relation on a Merge Sort algorithm

[亡魂溺海] 提交于 2019-12-08 02:01:54
问题 The question is : UNBALANCED MERGE SORT is a sorting algorithm, which is a modified version of the standard MERGE SORT algorithm. The only difference is that instead of dividing the input into 2 equal parts in each stage, we divide it into two unequal parts – the first 2/5 of the input, and the other 3/5. a. Write the recurrence relation for the worst case time complexity of the UNBALANCED MERGE SORT algorithm. b. What is the worst case time complexity of the UNBALANCEDMERGESORT algorithm?

Solving a recurrence relation using iteration method

扶醉桌前 提交于 2019-12-07 09:08:37
问题 Consider this example : T(n) = T(7n/8) + 2n I assumed T(1) = 0 and tried to solve it in the following way T(n) = T(7n/8) + 2n = T(49n/64) + 2.(7n/8) + 2n = T(343n/512) + 2.(7n/8).(7n/8)+ 2.(7n/8) + 2n = T(1) + 2n ( (7n/8)^i + ..... + 1) but I could not come to any conclusion about this. I am confused about what should I do in the next step. 回答1: Your approach is sound, but you'll see what to do if you rewrite it slightly differently: T(n) = T((7/8)^1 * n) + 2 * (7/8)^0 * n = T((7/8)^2 * n) +

Recurrence Relation: Finding Big O

烂漫一生 提交于 2019-12-06 20:32:32
I am trying to find the big O bound for the following recurrence relation: T(n) = T(n-1) + n^c, where c >= 1 is a constant So I've decided to solve this by using iteration: T(n) = T(n-1) + n^c T(n-1) = T(n-2) + (n-1)^c T(n) = T(n-2) + n^c + (n-1)^c T(n-2) = T(n-3) + (n-2)^c T(n) = T(n-3) + n^c + (n-1)^c + (n-2)^c T(n) = T(n-k) + n^c + (n-1)^c + .... + (n-k+1)^c Suppose k = n-1, then: T(n) = T(1) + n^c + (n-1)^c + (n-n+1+1)^c T(n) = n^c + (n-1)^c + 2^c + 1 I'm not sure if this is correct however, plus I would really appreciate some guidance as to how to derive Big O from this. Thanks a lot! Yes

recurrence relation on a Merge Sort algorithm

流过昼夜 提交于 2019-12-06 10:34:15
The question is : UNBALANCED MERGE SORT is a sorting algorithm, which is a modified version of the standard MERGE SORT algorithm. The only difference is that instead of dividing the input into 2 equal parts in each stage, we divide it into two unequal parts – the first 2/5 of the input, and the other 3/5. a. Write the recurrence relation for the worst case time complexity of the UNBALANCED MERGE SORT algorithm. b. What is the worst case time complexity of the UNBALANCEDMERGESORT algorithm? Solve the recurrence relation from the previous section. So i'm thinkin the recurrence relation is : T(n)

Solving recurrence T(n) = 2T(n/2) + Θ(1) by substitution

北慕城南 提交于 2019-12-06 01:48:37
So I am pretty sure it is O(n) (but it might not be?), but how do you solve it with substitution? If you assume T(n) <= c * n, what is the induction steps? First of all,I'd like to assume clearly that Θ(1)=k,some constant. Next,proceeding using substitution method, we get T(n)=2T(n/2)+Θ(1) =2T(n/2)+k =2{2T(n/4)+k)+k =4T(n/4)+3k =... =n.T(1)+(n-1)k =n.k+(n-1)k =2nk-k =O(n). If you assume it as T(n) <= c * n ,you should start with T(1) and assume for T(n) to be correct,and then proceed to show that it is correct for T(n+1) by using the assumption for T(n). BTW,your assumption was right! For

How to solve the recursive complexity T(n) = T(n/4)+T(3n/4)+cn

旧巷老猫 提交于 2019-12-05 22:12:11
I am solving this recurrence using a recursion tree. The total cost of each level is n, and the depth of the tree is between log (n) base 4 and log (n) base 4/3 . Intuitively, I expect the solution to be at most the number of levels times the cost at each level. O(cn log (n) base 4/3) = O(n log n) . I was wondering if my approach towards the problem, and my solution is correct? Think of it this way: for the first log 4 n layers of the recursion tree, the sum of the work across those layers will be cn, because if you sum up the total sizes of all the subproblems, it should total n so the total

Solving a recurrence relation using iteration method

爱⌒轻易说出口 提交于 2019-12-05 13:31:39
Consider this example : T(n) = T(7n/8) + 2n I assumed T(1) = 0 and tried to solve it in the following way T(n) = T(7n/8) + 2n = T(49n/64) + 2.(7n/8) + 2n = T(343n/512) + 2.(7n/8).(7n/8)+ 2.(7n/8) + 2n = T(1) + 2n ( (7n/8)^i + ..... + 1) but I could not come to any conclusion about this. I am confused about what should I do in the next step. Your approach is sound, but you'll see what to do if you rewrite it slightly differently: T(n) = T((7/8)^1 * n) + 2 * (7/8)^0 * n = T((7/8)^2 * n) + 2 * (7/8)^1 * n + 2 * (7/8)^0 * n = T((7/8)^3 * n) + 2 * (7/8)^2 * n + 2 * (7/8)^1 * n + 2 * (7/8)^0 * n . .

How to solve for this recurrence T(n) = T(n − 1) + lg(1 + 1/n), T(1) = 1?

牧云@^-^@ 提交于 2019-12-05 12:40:35
I got stuck in this recurrence: T(n) = T(n − 1) + lg(1 + 1/n), T(1) = 1? for a while and it seems the master method cannot be applied on this one. We have: lg(1 + 1/n) = lg((n + 1) / n) = lg(n+1) - lg(n) Hence: T(n) - T(n - 1) = lg(n + 1) - lg(n) T(n-1) - T(n - 2) = lg(n) - lg(n - 1) ... T(3) - T(2) = lg(3) - lg(2) T(2) - T(1) = lg(2) - lg(1) Adding and eliminating, we get: T(n) - T(1) = lg(n + 1) - lg(1) = lg(n + 1) or T(n) = 1 + lg(n + 1) Hence T(n) = O(lg(n)) Same answer as the other correct answer here, just proved differently. All the following equations are created from the given

Can someone help solve this recurrence relation? [closed]

不问归期 提交于 2019-12-04 17:02:28
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . T(n) = 2T(n/2) + 0(1) T(n) = T(sqrt(n)) + 0(1) In the first one I use substitution method for n, logn, etc; all gave me wrong answers. Recurrence trees: I don't know if I can apply as the root will be a constant. Can some one help? 回答1: Let's look at the first one. First of all, you need to know T(base case).