Suppose you have been given an MXN bitmap, representing an array M [1.m, 1. All are 0 or 1. One single block is a formula M [i .. i0, j .. j0] in which every bit is equal to 1. Describe and analyze an efficient algorithm to find an all-one block in M with maximum area
I am trying to create a dynamic programming solution. But my recurring algorithm runs in O (N ^ N) time, and even after memoanization I can not think of bringing it down under the O (N ^ 4). Can anyone help me find a more efficient solution?
It's just an idea, and I'm not sure it's working.
To define A (I, J) (D, DJ), (i, j) to all blocks of (i + di, j + dj), this means that m < X, y] for = 1 and i
Define A (i, j) (di, dj) Max-block if any A (I, J) (D + 1, DJ) and A (I, J ) (DI, DG + 1).
Each (i, j) we can control the list, the maximum of blocks is called (i, j), it is called. The maximum length of the list (M-I + 1, N-J + 1) & lt; = Min (m, n).
L (i, j) only depends on M [i, j], L (I + 1, J) and L (I, J + 1). I think that L (I, J) L (I + 1, J) and L (I, J + 1) can be constructed in linear time, it reminds me on the merger of sorted lists. With L (I, J), L (I, J) seems to have maximum (D * DJ) for A (I, J) (D, DJ). Specifies the maximum maximum one-one of these values.
The complexity required in this approach is n * m * minutes (m, n) ~ = n ^ 3 and minimum (m, n) of the last two rows.
Comments
Post a Comment