Please help me the algorithm
A matrix of dimensions n*n contains only zeros and ones as elements. Write psuedo
code to find the closest non zero element for every element with least complexity.
• Distance is Euclidean
Hint
• First solve for one dimentsion that is for every column individually.
• Then use the results for two dimensional problem.
Judging Criteria
• Least complexity of the solution
Example
Input Matrix
0 0 0
0 0 0
0 0 1
Output
Sqrt(8) sqrt(5) 2
Sqrt(5) sqrt(2) 1
2 1 0