The complexity of above code is exponential.
Here is the simple recurrence for the given problem

F(n) = 2*F(n-1) + F(n-2) + F(n-3)              for n >= 4

where F(1) = 2
            F(2) = 5
            F(3) = 13
precompute the values and each query will then be O(1)

On Thu, Aug 23, 2012 at 8:22 PM, bala bharath <bagop...@gmail.com> wrote:

> Can u please explain ur code..!!!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to