Question: def find_in_grid (word) : for K = [ 0 :nrows- 1 ]: for L = [ 0 :ncols- 1 ]: if can_form_word(K, L, word): return

def find_in_grid(word): for K = [0:nrows-1]: for L = [0:ncols-1]: if can_form_word(K, L, word): return true return false def can_form_word(x, y, word): if word.is_empty(): //base case, can always form '' return true if grid[x][y] == word[0]: //found first character for K = [-1:1]: for L = [-1:1]: if can_form_word(x+K, y+L, word[1:]): //check the neighbours for the rest return true return false 

This is a pseudocode I wrote to allow user to enter words found in the grid. I need help coding it.

This is my already written code that creates a grid:

# include  # include  # include  int x; int y; char grid [10] [10]; int z; int j; int main() { // declare array with alphabet char alphabet[26] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' }; printf ("Insert the width (x) and height (y) of the grid "); scanf ("%d %d", &x, &y); for (z = 0; z for (j=0; j // print letters instead of dots grid [z] [j] = alphabet[rand() % 26]; } } for (z = 0; z for (j=0; j printf ("%c", grid [z] [j]); } printf (" "); } } 

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 Mathematics Questions!