GATE CSE
First time here? Checkout the FAQ!
x
0 votes
378 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 (76.2k points)   | 378 views

1 Answer

+4 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 (53.1k points)  
selected by


Top Users Apr 2017
  1. akash.dinkar12

    3508 Points

  2. Divya Bharti

    2542 Points

  3. Deepthi_ts

    2040 Points

  4. rude

    1966 Points

  5. Tesla!

    1768 Points

  6. Shubham Sharma 2

    1610 Points

  7. Debashish Deka

    1588 Points

  8. Arunav Khare

    1454 Points

  9. Kapil

    1424 Points

  10. Arjun

    1420 Points

Monthly Topper: Rs. 500 gift card

22,076 questions
28,040 answers
63,230 comments
24,135 users