If  the matrix is 4-connected, we can use the same matrix.
now we have to find the total number of connected components of a graph.
consider 
 1 1 1 0  0  1 1  0 1 
 0 1  1 1 0  0  1 0 0 
 1 1  0 1 0 1  1 1 0
 0  0 0 0 0  0  0 0 1
we can use bfs/dfs to mark the nodes as visited and thus total connected 
components  can be counted.


On Tuesday, 10 January 2012 07:09:46 UTC+5:30, ashgoel wrote:
>
> there is a matrix of 1 and 0
> 1 is a island and   0 is water
> 1-1 together makes one island
> calculate total no of islands
>
> Best Regards
> Ashish Goel
> "Think positive and find fuel in failure"
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/JiDXnyVHn4YJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to