Given a n*n grid with free spaces and obstacles in the form an n*n integer matrix. We need to find shortest between any two given points (x1,y1) and (x2,y2) through the free spaces. We are not allowed to move in diagonal. Please help me figuring out an algorithm for doing this.
Thanks in advance.
ajhais 0 Newbie Poster
Recommended Answers
Jump to Postajhais,
It should actually be a Breadth First Search (BFS), not a DFS.
Jump to PostIf you know that there is a way, why not go for it, why should one try all the ways possible? If you are lucky you would have chose the right path the first time. I would go for DFS. I believe one should use a stack and not queue.
All 7 Replies
csurfer 422 Posting Pro
ajhais 0 Newbie Poster
csurfer 422 Posting Pro
nucleon 114 Posting Pro in Training
csurfer 422 Posting Pro
nucleon 114 Posting Pro in Training
Prabakar 77 Posting Whiz
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.