Chambers In A Castle Algorithm

Posted by 7Aces on Programmers See other posts from Programmers or by 7Aces
Published on 2012-12-17T06:15:20Z Indexed on 2012/12/17 11:13 UTC
Read the original article Hit count: 313

Filed under:
|

Problem Statement -

Problem Statement

Given a NxM grid of 1s & 0s (1s mark walls, while 0s indicate empty chambers), the task is to identify the number of chambers & the size of the largest. And just to whet my curiosity, to find in which chamber, a cell belongs.

It seems like an ad hoc problem, since the regular algorithms just don't fit in. I just can't get the logic for writing an algorithm for the problem. If you get it, pseudo-code would be of great help!

Note - I have tried the regular grid search algorithms, but they don't suffice the problem requirements.

Source - INOI Q Paper 2003

© Programmers or respective owner

Related posts about algorithms

Related posts about graph