public boolean findTheExit() { return findTheExit(getStartRow(), getStartColumn(
ID: 3538289 • Letter: P
Question
public boolean findTheExit() { return findTheExit(getStartRow(), getStartColumn()); } /** * This recursive backtracking method exhaustively searches the maze for an * exit. It returns true if at the start row and start column set in the * constructor an exit was found. * * This method must also set these two instance variables when the exit is *found foundRow and foundCol = -1; * * Return false if an exit cannot be found from the start position. */ public boolean findTheExit(int row,int col){ //TODO: Complete this method boolean escaped = false; If course[row][col] is a blank space { set current location to '.'; if on the border, (a base case) { set escaped = trueset foundRow to the current row set foundCol to the current col } else { let escaped = (RP1) success of escaping below if still not escaped let escaped = (RP2) success of escaping right if still not escaped let escaped = (RP3) success of escaping above if still not escaped let escaped = (RP4) success of escaping left } if escaped let current location = 'O'
}
return escaped ; } // end findTheExit
how would you solve this using recursion?
public boolean findTheExit() { return findTheExit(getStartRow(), getStartColumn()); } /** * This recursive backtracking method exhaustively searches the maze for an * exit. It returns true if at the start row and start column set in the * constructor an exit was found. * * This method must also set these two instance variables when the exit is *found foundRow and foundCol = -1; * * Return false if an exit cannot be found from the start position. */ public boolean findTheExit(int row,int col){ //TODO: Complete this method boolean escaped = false; If course[row][col] is a blank space { set current location to '.'; if on the border, (a base case) { set escaped = true
set foundRow to the current row set foundCol to the current col } else { let escaped = (RP1) success of escaping below if still not escaped let escaped = (RP2) success of escaping right if still not escaped let escaped = (RP3) success of escaping above if still not escaped let escaped = (RP4) success of escaping left } if escaped let current location = 'O'
}
return escaped ; } // end findTheExit
how would you solve this using recursion?
Explanation / Answer
http://www.learningace.com/doc/5361095/ebf7c48e096dcb550d649d4063934592/obstaclecourse
Hope this is help ful to you
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.