GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Placement Papers  >  TCS
Go To First  |  Previous Question  |  Next Question 
 TCS  |  Question 19 of 23    Print  
given g(0)=1,g(1)=-1and g(n)=g(n-1)+g(n-2),find(6).

  
Total Answers and Comments: 3 Last Update: February 27, 2008     Asked by: ramesh 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: abhishek76
 
we can write g(6) as g(5)+g(4) (since g(n)=g(n-1)+g(n-2))
again g(5)=g(4)+g(3),
          g(4)=g(3)+g(2)
          g(3)=g(2)+g(1)
          g(2)=g(1)+g(0)=1-1=0(as given above)
     therefore,g(3)= 0-1=-1
                     g(4)=-1+0=-1
                     g(5)=-1-1=-2
   therefore, g(6)=g(5)+g(4)=-2-1=-3(ans)

Above answer was rated as good by the following members:
yoooooooooo
October 23, 2007 01:56:58   #1  
santosh        

RE: given g(0)=1,g(1)=-1and g(n)=g(n-1)+g(n-2),find(6)...
# substitute n 6

> g(6) g(5)+g(4)----------------(1)
# sub n 5
> g(5) g(4)+g(3)-----------------(2)

# sub n 4
> g(4) g(3)+g(2)------------------(3)
#sub n 3
> g(3) g(2)+g(1)--------------------(4)
# sub n 2
> g(2) g(1)+g(0)--------------------(5)

so
g(2) 0;
g(3) -1;
g(4) -1;
g(5) -2;


g(6) -3;


another method:

g(6) 5*g(1)+g(0)


so generalised solution is g(a) (a-1)*g(1) + g(o) where a is to find for the given equation g(n) g(n-1)+g(n-2)

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
February 25, 2008 02:35:00   #2  
abhishek76 Member Since: February 2008   Contribution: 1    

RE: given g(0)=1,g(1)=-1and g(n)=g(n-1)+g(n-2),find(6).
we can write g(6) as g(5)+g(4) (since g(n) g(n-1)+g(n-2))
again g(5) g(4)+g(3)
g(4) g(3)+g(2)
g(3) g(2)+g(1)
g(2) g(1)+g(0) 1-1 0(as given above)
therefore g(3) 0-1 -1
g(4) -1+0 -1
g(5) -1-1 -2
therefore g(6) g(5)+g(4) -2-1 -3(ans)

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
February 27, 2008 18:45:43   #3  
vigneshkumar1988 Member Since: February 2008   Contribution: 7    

RE: given g(0)=1,g(1)=-1and g(n)=g(n-1)+g(n-2),find(6).
g(6) g(5)+g(4)
now we dont know about g(5) g(4)
g(5) g(4)+g(3)
g(4) g(3)+g(2)
g(3) g(2)+g(1)
g(2) G(1)+g(0)

now on solving
g(2) -1
g(3) -2
g(4) -3
g(5) -5
g(6) -8

 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 1Overall Rating: -1    


 
Go To Top


 Sponsored Links

 
Related Categories
Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape