Question: IN JAVA I am trying to make bases cases for my code so the recurrsion can be just 2 loops controling the columns and rows

IN JAVAIN JAVA I am trying to make bases cases for my code

I am trying to make bases cases for my code so the recurrsion can be just 2 loops controling the columns and rows like in the photo below(in the findPath). I think my base cases Need to be "if already visisted, if not a word, if out of bounds, and if last letter", I might be missing some. I have Isword making my stack that calls into isPath and that is where most of my code is. If someone cna please help me with the code I need to write to do so that would be great! The begining there is a chunk of code that is suppose to check if it has been visited and i do not know how to use it.

public class GameBoard public static final int NUM ROWS4; public static final int NUM COLS 4; private static string[] GAME PIECES = { "RIFOBX", "IFEHEY", "DENOWS", "UTOKND", "HMSRAO", "LUPETS", "ACITOA", "YLGKUE", "QBMJ0A", "EHISPN", "VETIGN", "BALIYT", "EZAVND", "RALESC, "UWILRG", "PACEMD" private char[] [] board; private boolean [] [1 visited public String isword(String word) char pink word.charAt (0);//getting first letter /ow looks through path and wil give a boolean which equals findpath and goes to next path Stack pathSoFar, int row, int col) String pinkwordToFind. substring(0,1); for(int y=0; y; y++){ //first for 10op that controls the cols for(int x ; xchUMRONS; x++){//start of second for loop that controls the rows if(pink.equals(boardly [xl)) pathSoFar.push( item: "("H+","4y+" )"); //Now we have our first letter, time to find the second with recurrsion boolean a findPath(wordToFind. substring(),pathSoFar, x,y) //makes substring that starts at 1 instead of zero for our se //0n the x and y coordinates return false public class GameBoard public static final int NUM ROWS4; public static final int NUM COLS 4; private static string[] GAME PIECES = { "RIFOBX", "IFEHEY", "DENOWS", "UTOKND", "HMSRAO", "LUPETS", "ACITOA", "YLGKUE", "QBMJ0A", "EHISPN", "VETIGN", "BALIYT", "EZAVND", "RALESC, "UWILRG", "PACEMD" private char[] [] board; private boolean [] [1 visited public String isword(String word) char pink word.charAt (0);//getting first letter /ow looks through path and wil give a boolean which equals findpath and goes to next path Stack pathSoFar, int row, int col) String pinkwordToFind. substring(0,1); for(int y=0; y; y++){ //first for 10op that controls the cols for(int x ; xchUMRONS; x++){//start of second for loop that controls the rows if(pink.equals(boardly [xl)) pathSoFar.push( item: "("H+","4y+" )"); //Now we have our first letter, time to find the second with recurrsion boolean a findPath(wordToFind. substring(),pathSoFar, x,y) //makes substring that starts at 1 instead of zero for our se //0n the x and y coordinates return false

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!