Which is better between TOP DOWN and BOTTOM UP DP?
Top Down DP vs Bottom UP DP
Hey @Arnabiswas both of them have their pros and cons. While Top down uses Memoization and bottom up uses Tabulation.
Since Memoization is easy to code so if you are doing a question in which dp state is not a very complex one Top Down is easy to code
Since Memoization uses stack, tabulation provides additional memory space for calculations, and it is usually possible to write more memory efficient code using tabulation rather than memoization for example if we are calculating fibonacci digits we can do that in O(1) space complexity using tabulation but memoization will use O(N) stack space
For extremely complicated problems,you might have no choice but to do tabulation
In my experience I have seen most people use bottom up approach in competitive programming and I’ll recommend the same as well.