-
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 1 #27
Comments
Hi prof and others, I did not really understand the point of this exercise since, If one would draw a tree chart for the multiplication 3×4 according to the example (listing 3) in lecture 'Recursion' there will be no repeating sub-solutions. Meaning that when a sub-solution is stored in the dictionary it will not be used again. I am correct or am I missing the point? |
@HiImBono
|
|
|
|
|
|
Note: +++ Dynamic Multiplication Algorithm +++
|
print(test_multiplication(0, 0, ({}), 0)) #true |
Guys, I'd like to give some feedback if you don't mind. It seems like only the algorithm of @beccadelbens works. All the other algorithms contain at least one of the following two errors:
Hopefully, this is helpful. Correct me if I am mistaken. Cheers, |
|
@SeverinJB thank you for pointing out the errors:
|
Thank you @SeverinJB for your feedback, it was really helpful.
|
|
Hi all, Here my take on the exercise - source codes available online.
|
Write an extension of the multiplication function introduced in the lecture "Recursion", i.e.
def multiplication(int_1, int_2, solution_dict)
, by using a dynamic programming approach. This new function takes in input two integer numbers to multiply and a dictionary with solutions of multiplications between numbers, which can be used to retrieve directly the result of such multiplication if already present in it. The function returns the result of the multiplication and, at the same time, modifies the solution dictionary adding additional solutions when found.Accompany the implementation of the function with the appropriate test cases.
The text was updated successfully, but these errors were encountered: