TransWikia.com

Problem of application of HashTable in Fibonacci

Mathematica Asked on October 4, 2021

As we can see the example in ref/datastructure/HashTable

enter image description here

This code show the usage of HashTable,
Fib is the implement of Fibonacci Number with HashTable.

If we subtle adjust the value, for example Fib[1200] on my computer, we can find this problem:

Recursion depth of 1024 exceeded during evaluation

How can I make this version Fib useful[practical] like the plain memorization version?
without modify $RecursionLimit if possible.

f1[1]=1; f1[2]=1; f1[n_]:=f1[n]=f1[n-1]+f1[n-2]

What’s the benefits of HashTable in this example? Slower and Limited?

enter image description here

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP