GATE CSE
First time here? Checkout the FAQ!
x
+1 vote
629 views

What is the value of F(4) using the following procedure:

function F(K : integer)
integer;
begin
if (k<3) then F:=k else F:=F(k-1)*F(k-2)+F(k-3)
end;
  1. 5
  2. 6
  3. 7
  4. 8
asked in Algorithms by Veteran (79.1k points)   | 629 views

1 Answer

+5 votes
Best answer
Here f(1)=1

        f(2)=2

f(4) = f(3)*f(2)+f(1)

f(3)=f(2)*f(1)+f(0) =2*1+0=2

f(4)=2*2+1=5
answered by Veteran (56.5k points)  
selected by


Top Users Aug 2017
  1. ABKUNDAN

    4670 Points

  2. Bikram

    4556 Points

  3. akash.dinkar12

    3420 Points

  4. rahul sharma 5

    3124 Points

  5. manu00x

    2864 Points

  6. makhdoom ghaya

    2450 Points

  7. just_bhavana

    2136 Points

  8. Tesla!

    2042 Points

  9. stblue

    1930 Points

  10. joshi_nitish

    1686 Points


24,970 questions
32,072 answers
74,567 comments
30,150 users