what is the procedure for converting top down dp to bottom up dp?
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
what is the procedure for converting top down dp to bottom up dp?
Name |
---|
I am not really fit to give advice as of now but I started out with top down and lately I have been solving few dp questions on bottom up manner too.
Personally I like to think in this manner.
How can I come from the previous index to the current index. (When I am trying to solve in an iterative fashion)
With that thought I try to look for the recurrence relation and how many states would it include. (remaining are the initial conditions like dp[0], dp[1] etc)
For top down. It's necessary to start with the recurrence itself and see for the recursion tree. Followed by the number of states and if memoization is possible.
And I personally feel one shouldn't think of how to convert it since its not really required. So rather pick up whatever you are comfortable with. (dp with less states usually are better to be done in iterative manner, dp problems which may require more states probably >2 are better done in top down manner)
Anyways I have a fundamental problem of not being able to recognize a dp problem (mostly) during the contests so I don't even get the chance to work them out. (That is a huge difference since knowing whether you can apply dp to the problem or not makes all the difference.)
P.S- If you really want to convert top down to bottom up. Its not very different. The recurrence remains the same. You just need to see how you can convert your recursion into loops once you solve it with top down.