The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+4 votes
170 views

The recurrence equation

  • $T(1) = 1$
  • $T(n) = 2T(n-1) + n, n \geq 2$

evaluates to $a.2^{n+1} - bn - c$, what is the value of $100a+ 10b+c$?

 

 

 

asked in Algorithms by Active (1.4k points) | 170 views

1 Answer

+6 votes
Best answer

$T(1) = 1$

$T(n) = 2T(n-1) + n$

So, $T(2) = 2+2=4, T(3) = 11. T(4) = 26$.

We are given, $T(n) = a.2^{n+1} - b.n - c$

So,

$T(2) = 4 \implies 8a - 2b - c = 4 \rightarrow(1)$

$T(3) = 11 \implies 16a - 3b - c = 11 \rightarrow(2)$

$T(4) = 26 \implies 32a - 4b - c = 26 \rightarrow(3)$

$(2) - (1) \implies 8a - b = 7 \rightarrow(4)$

$(3)-(2) \implies 16a - b = 15 \rightarrow(5)$

$(5) - (4) \implies 8a = 8, a = 1$

Now, from $(4)$, we get $b = 1$.

From $(1)$ we get $c = 2$.

So, $100a + 10b + c = 112$.

 


Now, lets solve by recurrence.

$T(n) = 2T(n-1) + n \\=2^2T(n-2) + 2.(n-1) + n \\=2^{3}T(n-3) + 2^2 (n-2) + 2(n-1) + n\\= \dots\\= 2^{n-1}T(1) + 2^{n-2}.2+ 2^{n-3}3+ \dots + n\\= 2^{n-1} + 2. 2^{n-2} + 3. 2^{n-3} + \dots + n.2^{n-n}\rightarrow(1)$

This is an AGP series with $d=1$ and $r= 0.5$. But I'm not using its properties. Multiplying (1) by 2 gives,

$2.T(n) = 2^{n} + 2. 2^{n-1} + 3. 2^{n-2} + \dots + n.2^{1} \rightarrow(2)$

$(2) - (1) \implies T(n) = 2^n + 2^{n-1} + 2^{n-2} + \dots +2^1 - n \\= 2^{n+1} - 2 - n.$

$\because 2^1 + 2^2 + \dots +2^n = 2^{n+1} - 1 - 2^0 = 2^{n+1} - 2$

So, $a = 1, b = 1, c = 2$ (care for the negative sign in equation of question)

answered by Veteran (326k points)
selected by

Related questions

+2 votes
1 answer
1
+1 vote
2 answers
2
0 votes
2 answers
3
asked in Algorithms by Rahul Jain25 Veteran (12.3k points) | 136 views


Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

29,017 questions
36,845 answers
91,385 comments
34,723 users