Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 JAVAimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

3rd Edition

0471418455, 978-0471418450

More Books

Students also viewed these Databases questions