Given a $n*m$ grid, some $1*1$ squares are blocked(can't be entered) and some are unblocked(can be entered).What is the algorithm which prints the shortest path, such that the path covers all unblocked $1*1$ squares in a $n*m $ grid ?The starting point is given to be :$(startx,starty)$.A $1*1$ square can be visited more than once, but all $1*1$ squares should be visited at least once and the length of path has to be minimized.Path can end any where, when there are no more unvisited $1*1$ squares.I have thought of dfs, but that doesn't seem to minimize the length of the path.
Algorithm to traverse all unblocked $1*1$ squares in a $n*m$ grid
shortest path;square grid