what is the procedure for converting top down dp to bottom up dp?
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 160 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | Dominater069 | 154 |
8 | awoo | 154 |
10 | luogu_official | 151 |
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.