Ask your own question, for FREE!
Computer Science 17 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!
Latest Questions
Jalissa21: What does adenoma mea?
19 minutes ago 2 Replies 0 Medals
Twilightt: How Can We Prevent Gun Violence in American Schools?
19 minutes ago 4 Replies 1 Medal
Twaylor: possible?
2 days ago 5 Replies 0 Medals
Arriyanalol: hekp
4 days ago 33 Replies 0 Medals
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!