Connected Component Labelling
I have asked a similar question some days ago, but I have yet to find an efficient way of solving my problem. I'm developing a simple console game, and I have a 2D array like this: 1,0,0,0,1 1,1,0,1,1 0,1,0,0,1 1,1,1,1,0 0,0,0,1,0 I am trying to find all the areas that consist of neighboring 1's (4-way connectivity). So, in this example the 2 areas are as following: 1 1,1 1 1,1,1,1 1 and : 1 1,1 1 The algorithm, that I've been working on, finds all the neighbors of the neighbors of a cell and works perfectly fine on this kind of matrices. However, when I use bigger arrays (like 90*90) the