queensAttackIneffective - memory-ineffective, allocates a buffer matrix of the n * n size for its internal purposes. The complexity is about O(k + 4 * (n-1)), where k is the number of obstacles and n is the board size. But this algorithm is more trivial.
queensAttack - much more effective algorithm, doesn't allocate any extra memory except the memory for some local vars in the stack. The complexity is just O(k), where k is the number of obstacles.
queensAttackIneffective
- memory-ineffective, allocates a buffer matrix of then * n
size for its internal purposes. The complexity is aboutO(k + 4 * (n-1))
, wherek
is the number of obstacles andn
is the board size. But this algorithm is more trivial.queensAttack
- much more effective algorithm, doesn't allocate any extra memory except the memory for some local vars in the stack. The complexity is justO(k)
, wherek
is the number of obstacles.