GATE CSE
First time here? Checkout the FAQ!
x
+4 votes
145 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.3k points)   | 145 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 (281k points)  
selected by

Related questions

+2 votes
1 answer
1
+1 vote
3 answers
2
0 votes
2 answers
3
asked in Algorithms by Null&Void Active (1.8k points)   | 37 views


Top Users Mar 2017
  1. rude

    5246 Points

  2. sh!va

    3054 Points

  3. Rahul Jain25

    2920 Points

  4. Kapil

    2732 Points

  5. Debashish Deka

    2602 Points

  6. 2018

    1574 Points

  7. Vignesh Sekar

    1440 Points

  8. Bikram

    1432 Points

  9. Akriti sood

    1420 Points

  10. Sanjay Sharma

    1128 Points

Monthly Topper: Rs. 500 gift card

21,553 questions
26,901 answers
61,258 comments
23,269 users