Grokking Dynamic Programming Patterns for Coding Interviews
Ask Author
Back to course home

0% completed

Vote For New Content
In the Bottom-up Dynamic Programming example, the diagram is confusing.I underst...

Ray

Jun 20, 2022

In the Bottom-up Dynamic Programming example, the diagram is confusing.

I understand with 0 capacity (the column), you have 0 profit.

I'm having a hard time understanding why the row (index 0) gets filled with all 1's. There are 4 items (various weights & profits). Does the index mean item count? If so, you should be able to have more profit with more capacity in the 1st row. It shouldn't be filled with all 1's. So I am not understanding the diagram ( https://lwfiles.mycourse.app/systemdesign-public/10cd89386658f0f18522e58386389d80.png ).

0

0

Comments
Comments
R
Ray 3 years ago

This image is still really confusing https://lwfiles.mycourse.app/systemdesign-public/034f26f158ef4df409c5d040e7188299.png

What does index represent? The current item (included or...

J
JOD Developer3 years ago

r the reason they are all filled with one at row zero is because in the beginning you've got only one item and capacity/profit of that object is 1 thats why the all have 1. As u iterate and get more items then u have to make various appropriate decisions.

On this page

Problem Statement

Try it yourself