can anyone solve this problem in java. A matrix will be inputed containning only 0 and 1's. now the 1's are obstacles and 0's are paths. write a program for a pathway to complete any given maze staring from the top left square and ending in the bottom right square
you must have use BFS or DFS algo :P
@xaadi1993 can you explain what is BFS or DFS algo???
Breath first search algoritham and Depth first search algoritham so you can find way from the very first block to the last one you can go to youtube if u like to learn
Like xaadi1339 said, look up BFS or DFS. Basically, you create a queue. Then you queue all the positions adjacent to the starting point. Dequeue the head node and check to see if it is the exit. If it's not, queue all the adjacent positions. Keep repeating until the node checked is the exit. An alternative method could be done using a stack. You keep adding nodes to the stack and mark decision points. When you reach a dead end, you pop stack until the last decision point. Repeat until exit.
Join our real-time social learning platform and learn together with your friends!