I need some help fixing this problem with the code i made. It uses depth first search to go through the matrix to find all possible words in a boggle board. However it when i run it nothing comes out even though it goes through everything. Any tips here is the code.
checkTable is an x by x boolean table initialized to be false.
private void wordSearch(String prefix, int row, int col)
// checks to see if it is out of bounds
if (row < 0 || col < 0 || row >= size || col >= size)
// see if the letter has been used yet
// the letter has been visited
checkTable[row][col] = true;
//is the prefix in the dictionary
prefix = prefix + board.getLetter(row, col);
if (dictionary.contains(prefix) && prefix.length() > 2)
// looks at all adjacent
for (int i = -1; i <= 1; i++)
for (int j = -1; j <= 1; j++)
wordSearch(prefix, row + i, col + j);
checkTable[row][col] = false;
dictionary.contains checks to see if the word is in the dictionary.
if you need any more information let me know.