IDS-3250 Lecture Notes - Lecture 1: Word Search, Logic Gate

11 views3 pages

Document Summary

Look for word in 2d grid of characters. // rows and columns in given grid static int r, c; // for searching in all 8 direction static int[] x = { -1, -1, -1, 0, 0, 1, 1, 1 }; static int[] y = { -1, 0, 1, -1, 1, -1, 0, 1 }; // this function searches in all 8-direction from point. // (row, col) in grid[][] static boolean search2d(char[][] grid, int row, int col, string word) // if first character of word doesn"t match with. // given starting point in grid. if (grid[row][col] != word. charat(0)) return false; int len = word. length(); // starting from (row,col) for (int dir = 0; dir < 8; dir++) // for current direction int k, rd = row + x[dir], cd = col + y[dir]; // match remaining characters for (k = 1; k < len; k++)

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents