-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lecture "Dynamic programming algorithms", exercise 2 #28
Comments
|
|
Note: +++ Dynamic Merge Sort with Test Cases +++
|
@SeverinJB Sevi, could you explain your thinking process behind editing the merge() algorithm definition, when you added
in its definition? I am trying to understand why this is necessary to make your merge_sort_dp() work. As I tried your code without editing merge() in the way you did, and it doesn't work. |
My approach, based on a mix of Severin's and Eleonora's approaches but with a focus on labelling each of the 5 steps of dynamic programming. I created an ancillary function list_to_key() to handle the key label creations for each element in the dictionary separately.
@SeverinJB I figured it out the merge() edit on my own! We need to use copies of the lists, because otherwise our dictionaries are corrupted every time we run the merge() function. |
Hi @delfimpandiani, Sorry for not coming back to your questions earlier. For clarification: Hopefully, this helps. |
Hi all, Here my take on the exercise - source codes available online.
|
I didn't see the solution of the exercise again. I tried to create an algoritm but I'm not sure of the efficiency, because it returns the result, but maybe it iterates in an unneccessary way. Could it work?
|
Write an algorithm for using the merge sort (introduced in the previous lecture) so as to use a dynamic programming approach in case the same list of books must be ordered twice or more times during the algorithm execution – see the informal example introduced in Section "Remembering solutions to sub-problems" of this lecture notes.
Accompany the implementation of the function with the appropriate test cases.
The text was updated successfully, but these errors were encountered: