Dynamic Programming21 sections · 916 units
Open in Course

Complexity Analysis

Time and space

Time: O(m2nT)O(m \cdot 2^n \cdot T), where mm is columns, nn is rows, and TT is average transitions per profile. For typical tiling, TT is small (constant or logarithmic in 2n2^n). Space: O(2n)O(2^n) with a rolling array (store only current and previous column), otherwise O(m2n)O(m \cdot 2^n).

With n10n \leq 10, 2n10242^n \leq 1024, which fits easily. Precomputing transitions takes O(2n2n)O(2^n \cdot 2^n) worst case, but practice is faster because not all transitions are valid.