From the course: Fundamentals of Dynamic Programming
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Breaking down the flowerbox problem into subproblems - Python Tutorial
From the course: Fundamentals of Dynamic Programming
Breaking down the flowerbox problem into subproblems
- [Instructor] Let's summarize our goal in the flower box problem. We have a flower box with a few places to plant flowers. Each location has nutrients that influence how tall the flower will be. You can't plant flowers next to each other, and we want to maximize the total height of all the planted flowers. In this example the best option is to plant it in locations one and four indexing from zero. In general the greedy approach of picking the most nutrient-dense locations doesn't always work. So what can we do instead? Well, at any given spot, we can choose to plant a flower or not. If we do plant a flower in that spot, the previous spot is now off limits, but you can optimize the rest of the flower box two locations down all the way to the beginning. It doesn't matter where you plant flowers in that segment as it has no effect on the current location. On the other hand we can choose to not plant a flower in the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Planting flowers in a flowerbox1m 56s
-
(Locked)
Breaking down the flowerbox problem into subproblems3m 27s
-
(Locked)
Solving the flowerbox problem in Python1m 19s
-
(Locked)
How many ways can you make change?1m 52s
-
(Locked)
Breaking down the change-making problem into subproblems4m 23s
-
(Locked)
Solving the change-making problem in Python2m 13s
-
-
-
-