Clarification of memoization in exercise `coordinate-transformation`
See original GitHub issueContext
In the last task of exercise coordinate-transformation
, the instruction introduces memoization as following:
Memoizing is sometimes called dynamic programming, it allows for expensive operations to be done only once since their result is remembered.
However, the instruction also says:
[…] returns a new function that remembers the inputs to the supplied function so that the last return value can be “remembered” and only calculated once if it is called again with the same arguments.
which says that the function should only remember its last input and result.
Problem
This is from a computer science point of view.
Dynamic programming usually memoize all previous computation. Memoizing all the previous results enables dynamic programming algorithms to compute a certain problem only once.
In this task of exercise coordinate-transformation
, it only asks to “remember” the last input and result, which does not completely match the idea of dynamic programming in general.
The immediate disadvantage the above mismatch introduce could be:
- The learner confuses the concept of dynamic programming with caching or something else and meets with obstacles later when studying dynamic programming.
- The learner who knows about dynamic programming tries to do dynamic programming and fails the test so they get confused.
Potential solutions
- Rephrase the quote and indicate that the problem is different from general dynamic programming problem, something like:
Memoizing is sometimes called dynamic programming, it allows for expensive operations to be done only once since their result is remembered. Note that while in dynamic programming often all previous operations are remembered, in this exercise we only want to the last one to be remembered.
- Modify the task so it asks the learner to record all previous computations in stead of the just the last one.
- Add yet another task which asks the learner to record all previous computations.
Issue Analytics
- State:
- Created a year ago
- Comments:6 (6 by maintainers)
Top GitHub Comments
I would like to adopt solution 1 as well. For the PR, I am worried about the exact wording, so I guess we could discuss a bit first.
@SleeplessByte Thank you for your feedback on this.
I see the revised wording is better.
As for dropping references of dynamic programming, I am in favor of not doing so. I think the exercise introduces memoization, and it is indeed closely related to dynamic programming. Also, these kind of text adds a little sugar in the exercise.
I recognize that dynamic programming does not “usually” memoize, instead, it generally refers to bottom-up approaches. That was a mistake I made. However, in my experience, when dynamic programming does memoize, usually all previous results are remembered. But, that’s debatable.
For the intended use of
let
orvar
, I don’t think it would impose any real restriction. What one can do withlet
, theoretically, one could use aconst
with an object to achieve the same effect. But, I guess that is fine.That said, I revised the rewording from @SleeplessByte a bit. Hopefully, it would be an enhancement.
Grammar changed a little bit. Using
result
instead ofcomputation
to hopefully reduce confusion. Avoid indicating how much portion of dynamic programming memoizes, just saysome
.If we are happy about the wording, I would like to create a PR. Otherwise, we can continue to change it.
Wording looks fine to me.
Thanks!