c++ - Finding path in a char array -


I am working on a project and I am in a situation where I have nxn four array of signs a, b or c I must check whether the path of b is between the first and the last row. Example Yes Input:

Enter image details here

I I got stuck at this point? Should I optimize some famous algorithm for graph searching or is there a better way to solve this problem? Should I add the bool array to mark the room I have seen? Thanks in advance for your time!

Yes, you must adopt a graph algorithm to find a path from a source to the path target. In your case you have many sources (all in the first line of 'B') and many goals (in the last line of 'B').

The smallest route can be easily applied on the graph without any fluctuation. The difference in handling multiple sources is to initialize the queue only with all 'B' on the first line (and not one node).

Every b cell in your graph is a node, one edge between the two adjacent 'B' cells.

Note that BFS is completed (always gets a solution if someone is present) and optimal (finds the least path).

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -