GATE CSE
First time here? Checkout the FAQ!
x
+2 votes
156 views

asked in Algorithms by Loyal (4k points)  
retagged by | 156 views

1 Answer

+3 votes
Best answer
okay,it can be solved using Dynamic Programming

and once one is computed, it can be easily found by going through the table.

and we can write it like

T(12)=T(10)+T(9)

T(10)=T(8)+T(7)

T(9)=T(7)+T(6)

T(8)=T(6)+T(5)

T(7)=T(5)+T(4)

T(6)=T(4)+T(3)

T(5)=T(3)+T(2)

T(4)=T(2)+T(1)

T(3)=T(1)+T(0)

T(2)=T(0)+T(-1)

We need one function call for each unique T(x)

here we need function calls T(-1),T(0),T(1),T(2,)T(3),T(4),T(5),T(6),T(7),T(8),T(9),T(10),T(12)

13 function calls

so it should be the answer
answered by Veteran (18.4k points)  
selected by
Are..it was this easy..I was complicating it unnecessarily. Thanks :)
Happens!
Btw,whats the answer?

yes..ur answer is correct. But the explaination was this.

ya, they did the same! i did table manner, they did tree approach! do not worry. Same thing.Even they missed something in last level
ok..actually they did not count all function calls, and counted T(5) twice, so I assumed it to be wrong.
^ they r consistent :P


Top Users Jul 2017
  1. Bikram

    4910 Points

  2. manu00x

    2940 Points

  3. Debashish Deka

    1870 Points

  4. joshi_nitish

    1776 Points

  5. Arjun

    1506 Points

  6. Hemant Parihar

    1306 Points

  7. Shubhanshu

    1128 Points

  8. pawan kumarln

    1124 Points

  9. Arnab Bhadra

    1114 Points

  10. Ahwan

    956 Points


24,099 questions
31,074 answers
70,703 comments
29,407 users