Memoization in C

Memoization is a very useful as well as often needed optimization technique.I implement this, using an extra array to store the results.

Is there any more efficient way to achieve memoization in C/C++/Java?? Just if there is some way of getting it from cache?


Well, as far as I know, memoization is an optimization technique in the sense that there is a space-speed tradeoff, i.e. , you trade size for speed.

So, you consume more memory but on the other hand, you get a faster execution time for a code which would be otherwise too slow.

If I understood, your question is whether you can have this memoization bonus more “implicitly” without using the extra array yourself.

Truth is, I don’t know.

I know there are some languages which have some sort of “automatic memoization”, but, I guess internally, they all take the extra space…



Thanks Bruno. I do get that I have to compromise on size/memory when I use memoization. But is there any other way which is “faster” or “more efficient” than the array method?