4.11 Improving Performance Using Memoization
I once attended a bird show where a performer challenged a teenager to compete against a parrot in arithmetic. To the chagrin of the young fellow and the amusement of the viewers, the parrot swiftly replied to “what’s 200 times 50?" After the parrot aced the next few questions, the performer revealed the secret—the parrot simply repeated memorized answers to scripted questions. In this section we’ll use a similar technique, but rather than calling it memorization, we’ll term it memoization, continuing the tradition in our field of giving odd names to concepts.
In the previous section you learned a technique to make recursive calls memory-efficient. Recursion in essence is a way to solve a problem ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access