Quiz: Greedy Algorithms
Take this short quiz on greedy algorithms.
1
Consider the following algorithm for the Money Change Problem.
def change(money):
if not money:
return 0
max_coin = max([coin for coin in (1, 5, 10) if coin <= money])
return X
Which statement should replace X
to complete the code above?
A)
1 + change(money + max_coin)
B)
1 + change(money - max_coin)
C)
1 - change(money - max_coin)
D)
1 + change(money * max_coin)
Question 1 of 60 attempted
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.