1

There are many posts on the net stating - "Cut Rectangle in Minimum no. of Squares" problem can be solved by DP. For ex :- Cut rectangle in minimum number of squares

But, even the DP strategy described in the above post doesn't yield optimal solution. For ex :- for rectangle 11x13, the optimal solution occurs when the rectangle is not divided into 2 parts. (See - http://int-e.eu/~bf3/squares/view.html#13,11)

Can this problem really be solved optimally by a DP approach? If not, how to obtain optimal solution for all possible cases?

  • 2
    DP is just a way to optimise an algorithm (and never a solution to anything on its own). That algorithm would've existed with or without DP. By focusing on DP, what you're really doing is trying to make "premature optimisation" a design criteria. – Brendan Dec 02 '17 at 09:07
  • @Brendan Ok, I understood that DP is nothing but a tool for algorithm optimization. So, how do I solve this question to handle all cases optimally? And which algorithm can be used? – Abhinav Kumar Dec 05 '17 at 09:58
  • I'm not sure what the best algorithm is. I'd be tempted to start by finding solutions to`h*w = A*1*1 + B*2*2 + C*3*3 + D*4*4 + E*5*5 + F*6*6 + ....`; then (for each solution found) try to arrange the squares on the grid to make sure they fit; and if they do fit, calculate a `score = sum of (A , B, C, D, ...)` and see if its score is better than a previously seen score. The optimal solution would just be whatever has the best score after trying all possibilities (note: I'm also not sure if it's possible to have 2 or more equally optimal solutions). – Brendan Dec 05 '17 at 13:59

0 Answers0