Ask your own question, for FREE!
Computer Science 22 Online
OpenStudy (anonymous):

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

OpenStudy (anonymous):

you must have use BFS or DFS algo :P

OpenStudy (anonymous):

@xaadi1993 can you explain what is BFS or DFS algo???

OpenStudy (anonymous):

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

OpenStudy (anonymous):

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.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!