Memoization

garanews's avatar
Published Mar 26, 2022Updated Oct 26, 2022
Contribute to Docs

Memoization is a technique that improves the speed of a program by storing any new inputs for future reference, if needed. This cuts down on any repeated computations in the program where the same inputs are being used to return the same result.

This technique gets its name from the Latin word, “memorandum”, which means to be remembered. Memoization can be applied to many contexts in computer programming, including:

  • Making calls to recursive or pure functions where some calculations use the same inputs and return the same outputs.
  • Fetching from the server with the same base API endpoints.

Memoization can be implemented in most programming languages, including JavaScript and Python. However, while memoization saves performance time, it comes with a cost in memory space since it is caching results that were already calculated.

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • New to coding? Start here and learn programming fundamentals that can be helpful for any language you learn.
    • Beginner Friendly.
      2 hours

All contributors

Contribute to Docs

Learn General on Codecademy

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • New to coding? Start here and learn programming fundamentals that can be helpful for any language you learn.
    • Beginner Friendly.
      2 hours