![]() |
| ||
| Re: fibonacci Oh, ok. so changing the array to static solved everything. It's still really slow, compared to this one: #include <ctime>But that was expected; we get extra credit for programming both and timing the two. I'm still frustrated that I can't do static int fibArray [ n ] instead of 25, or some other constant value. |
| ||
| Re: fibonacci >so changing the array to static solved everything. No, changing the array to static and actually using the values you've cached solved everything. If you don't to the latter, your code won't be any faster than the usual recursive solution. >It's still really slow, compared to this one Your function might be slow, but mine is a hair faster in my tests than the code you're referring to. I've included a little test below. >I'm still frustrated that I can't do static int fibArray [ n ] >instead of 25, or some other constant value. A better alternative is to pass a buffer to the function rather than use a static or global array. I've made that change in the test below. #include <ctime> |
| ||
| Re: fibonacci Oh ok great. thanks for the help! It's working great! |
| All times are GMT -4. The time now is 11:50 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC