Re: Fibonnaci
- From: "buda" <kulghan@xxxxxxxxxxx>
- Date: Fri, 9 Dec 2005 10:58:09 +0100
"Jordan Abel" <jmabel@xxxxxxxxxx> wrote in message
news:slrndpi5k5.2q4r.jmabel@xxxxxxxxxxxxxxxx
> On 2005-12-09, Richard Heathfield <invalid@xxxxxxxxxxxxxxx> wrote:
>> Write it. See how slow it is? Find out why. Hint: use printf.
>>
>> Now think about how you could make it a lot faster. Hint: think about
>> arrays.
>
> All that's needed to change the worst-case performance to linear is a
> two-element cache.
I think Richard tryed to explain the process... how to move from a top down,
recursion-based solution to a memoized recursion, and then to a bottom-up
solution (building that same array that was used for memoization from 0 to
n). This is infact the best you can do if you need to keep all of the first
n Fibonacci numbers - it is unclear if the OP needs this, or he just wants
to write them out. Also, your comment is covered in the last "idea" Richard
gives.
.
- References:
- Fibonnaci
- From: MARQUITOS51
- Re: Fibonnaci
- From: Richard Heathfield
- Re: Fibonnaci
- From: Jordan Abel
- Fibonnaci
- Prev by Date: C, really portable?
- Next by Date: Re: C, really portable?
- Previous by thread: Re: Fibonnaci
- Next by thread: Help with type returned
- Index(es):
Relevant Pages
|