There is a N * N matrix, for eg., we can take a 3 * 3 matrix,
3 6 5 9
4 5 0 8
8 7 9 0
3 4 0 1
The problem is to traverse all the '0's in the given matrix by passing through minimum numbers. For eg.,if we start from 3 (1,1), we can reach (2,3) by passign through (1,1)--> (1,2)--> (2,3) but we have to take the way (1,1)-->(2,2)--> (2,3).since we have to use minimum weight in the path. (3+6 weight in the first case and 3+5 weight in the second case).
we have design an algorithm to traverse all the 0's with minimum weight in the path.
My algorithm : 1. Mark all the 0's in the given matrix and count. 2. BFS loop: Induce a BFS from any node to reach the 0's. exit loop once the 0's are found.
but the weight of the path should be the minimum to find the 0's, could anyone help me in solving this?