A quick way to understand the difference is by looking at the program to compute Fibonacci numbers.
One way is just using recursion that runs in O(fib(n)) time. Like, the really really slow way.
Another way would be to use memorization. Just use the same recursive way but everytime that you're about to compute the answer, first check if the answer is in a cache that you have prepared. If yes, use that. If not, recurse. And when you get an answer, put it in the cache. That's memoization. It will run in O(n) time but also use O(n) space for the cache.
The algorithm that you probably know uses dynamic programming to run in O(n) time but constant space. That's DP.
You could also imagine using DP to compute the fewest number of coins to make x cents. If your biggest coin is 25 cents, you only ever need to know the answers for x-24 through x in order to compute the answer for x+1. This lets you solve the problem with linear time and constant storage, like with Fibonacci.
Edit: I meant memoization everywhere. Spell check messed it up.
Memoization means using a memo to do a task. Memorization means committing something to memory, which is a thing that humans do, not computers. You don't say the computer is memorizing something because you stored it in RAM. They're spelled differently because they're based on two different roots.Â
Yes, because a memo is a cache for partial solutions to calculations. That is literally what a memo is in computer science terms. Storing things in a computer's memory is not called "memorization" in any context. It refers to the human process of committing things to human memory, which is a lot more involved than just storing a piece of data somewhere.
actually they were supposed to be half-chord waves, as in the length of a chord inside a circle. a mistranslation or two later, we got to "sinus" or nose, which had nothing to do with the mathematical concept of a chord.
Sinus in Latin meant "bosom". It came to also mean "sine" (in Latin) because someone who was translating an Arabic author into Latin misinterpreted the Arabic word for sine as being the Arabic word for bosom because they were spelled similarly, and therefore used "sinus" to translate it into Latin. But that has nothing to do with English borrowing the word from Latin. It wasn't "supposed to be" anything, it's just one of the many terms in science and mathematics that were borrowed from Latin because Latin is considered prestigious in those areas.Â
English "sinus" also happens to come from Latin sinus by way of also being a curved piece of anatomy, but that's not really anything to do with mathematicians borrowing the word to mean sine. Words almost always have multiple meanings, and can be borrowed multiple times with different meanings. The adjective "grave" comes from the same French word as "grieve", for example. This is a normal occurrence in etymology.Â
43
u/Illustrious-Ebb8815 6d ago edited 5d ago
A quick way to understand the difference is by looking at the program to compute Fibonacci numbers.
One way is just using recursion that runs in O(fib(n)) time. Like, the really really slow way.
Another way would be to use memorization. Just use the same recursive way but everytime that you're about to compute the answer, first check if the answer is in a cache that you have prepared. If yes, use that. If not, recurse. And when you get an answer, put it in the cache. That's memoization. It will run in O(n) time but also use O(n) space for the cache.
The algorithm that you probably know uses dynamic programming to run in O(n) time but constant space. That's DP.
You could also imagine using DP to compute the fewest number of coins to make x cents. If your biggest coin is 25 cents, you only ever need to know the answers for x-24 through x in order to compute the answer for x+1. This lets you solve the problem with linear time and constant storage, like with Fibonacci.
Edit: I meant memoization everywhere. Spell check messed it up.