The memoization functional design pattern stores the results of key functions so that overall processing efficiency is increased. When there are specific processes that have the same output each time they are invoked, it is less costly, from a processing time perspective, to cache the results instead of recalculating them each time.
The Fibonacci sequence is often used to demonstrate memoization, so it shall be used here as well.
Fibonacci numbers are a mathematical construct where each number is the sum of the two preceding numbers. The Fibonacci sequence starts with the numbers 0 and 1.
Let's start by looking at a standard implementation of the Fibonacci sequence. Here is the source code:
public class FibonacciTest1 {
public static int computeFibonacciNumber(int number) {
// this checks for the fibonacci base of 0 and...