Browse over 20 million
homework answers & study documents

Computer Science

Pseudo code for wordsearch java

Type

Homework

Rating

Showing Page:
1/5
WordFind START
DECLARATION
Declare a matrix as _puzzle to keep all the letter sof the word
Declare an array as _words which would keep all the words read from
the file
Declare string as _word2Find to hold the word to find in the puzzle
LOGIC
1. Read the words from file in to _words array
2. Determine the size of the matrix puzzle
3. Call InitGameBoard
4. Ask the user to enter the word he/she wants to find in the puzzle
and store it in _word2Find.
5. Call SearchLeft to Search the _word2Find in left direction, if
found goto Step 14
6. Call SearchRight to Search the _word2Find in right direction, if
found goto Step 14
7. Call SearchUp to Search the _word2Find in up direction, if found
goto Step 14
8. Call SearchDown to Search the _word2Find in down direction, if
found goto Step 14
9. Call SearchLeftUp to Search the _word2Find in diagonal up-left
direction, if found goto Step 14
10. Call SearchLeftDown to Search the _word2Find in diagonal down-
left direction, if found goto Step 14
11. Call SearchRightUp to Search the _word2Find in diagonal up-right
direction, if found goto Step 14
12. Call SearchRightDown to Search the _word2Find in diagonal up-
right direction, if found goto Step 14
13. Print _word2Find not found in the _puzzle.
14. Program ends.
WordFind END
InitGameBoard START
1. For each word in the array _words
1.1 generate a random number between 1 and 8 to decide the direction
of the word layout(left, right, up, down, diagonal in all directions) in the
puzzle.
1.2 Populate the entire _puzzle with random letters
1.3 Generate 2 random numbers (within the range of the _puzzle size)
to determine the starting index of the word. Let _X, _Y be the the distance from
left and top border of the _puzzle matrix
1.4 If the word fits((word length + Y) <= width or height of the
matrix) in the _puzzle starting from _X in _Y direction
3.4.1 Replace the populated letters in the _puzzle from _X in
_Y direction with the letters of the word
1.5 else Goto Step 1.3
InitGameBoard END
SearchLeft START
DECLARATION
Declare and initialize an int as _C=0 to keep track of the word
count
LOGIC
1. for each _X from 0 to _puzzle.length-1
1.1 for each _Y from _puzzle[i].length-1 to 0
1.1.1 If character at location _C in the _word2Find ==
_puzzle[_X][_Y] then
1.1.1.1 _C = _C + 1
1.1.1.2 If _C == _word2Find.length then

Sign up to view the full document!

lock_open Sign Up
1.1.1.2.1 Highlight the word in the _puzzle
and display the _puzzle
1.1.1.2.2 Return true
1.1.2 Else _C = 0
2. return false;
SearchLeft END
SearchRight START
DECLARATION
Declare and initialize an int as _C=0 to keep track of the word
count
LOGIC
1. for each _X from 0 to _puzzle.length-1
1.1 for each _Y from 0 to _puzzle[i].length-1
1.1.1 If character at location _C in the _word2Find ==
_puzzle[_X][_Y] then
1.1.1.1 _C = _C + 1
1.1.1.2 If _C == _word2Find.length then
1.1.1.2.1 Highlight the word in the _puzzle
and display the _puzzle
1.1.1.2.2 Return true
1.1.2 Else _C = 0
2. return false;
SearchRight END
SearchTop START
DECLARATION
Declare and initialize an int as _C=0 to keep track of the word
count
LOGIC
1. for each _Y from 0 to _puzzle[0].length-1
1.1. for each _X from _puzzle.length-1 to 0
1.1.1 If character at location _C in the _word2Find ==
_puzzle[_X][_Y] then
1.1.1.1 _C = _C + 1
1.1.1.2 If _C == _word2Find.length then
1.1.1.2.1 Highlight the word in the _puzzle
and display the _puzzle
1.1.1.2.2 Return true
1.1.2 Else _C = 0
2. return false;
SearchTop END
SearchDown START
DECLARATION
Declare and initialize an int as _C=0 to keep track of the word
count
LOGIC
1. for each _Y from 0 to _puzzle[0].length-1
1.1. for each _X from 0 to _puzzle.length-1
1.1.1 If character at location _C in the _word2Find ==
_puzzle[_X][_Y] then
1.1.1.1 _C = _C + 1
1.1.1.2 If _C == _word2Find.length then
1.1.1.2.1 Highlight the word in the _puzzle
and display the _puzzle
1.1.1.2.2 Return true
1.1.2 Else _C = 0
2. return false;

Sign up to view the full document!

lock_open Sign Up

Sign up to view the full document!

lock_open Sign Up

Anonymous
I was on a very tight deadline but thanks to Studypool I was able to deliver my assignment on time.

Anonymous
Heard about Studypool for a while and finally tried it. Glad I did caus this was really helpful.

Anonymous
I always get good papers on this site. They are detailed and address all the requirements I need.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4