Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need help creating a word finder in JAVA. The program should allow the user to input AxB matrix of characters and a string word.
I need help creating a word finder in JAVA. The program should allow the user to input AxB matrix of characters and a string word. The program should be able to find the word in the given matrix. The following rules apply:
The word can be formed in any direction forward backwards, forwards diagonal, backward diagonal, etc.
The same letter cant be reused to form the word
Must follow any of the above directions with their combination while forming the words.
Input Format Your code must read from standard input no file Io is allowed
The first line of the input consists of integers, A B and C Here A number of rows in the matrix, B number of columns in the matrix, and C number of words you need to find from this matrix. Then A lines represent the rows input characters, where each line has B characters separated by space. After A lines, there will be C lines of words. You need to find these words in the matrix. Similarly, D test cases will be provided in the above format. The program should use a backtracking strategy. Hint : Have a wrapper function. From the wrapper function, call the back tracking worker function for each box in the matrix until you find a solution or you decide there is no solution.
Sample input:
C B A B
B N O D
M D E E
ABC
BAOED
CNE
NEC
NEED
NEEDON
Output Format
Sample output for input
Looking for ABC
C B A
Looking for BAOED
B A
O
D E
Looking for CNE
C
N
E
Looking for NEC
NEC not found!
Sample input:
c o m p
a m a p
a p s s
x y z q
mop
comp
omo
maa
Sample output
Looking for mop
mop not found!
Looking for comp
c o m p
Looking for omo
omo not found!
Looking for maa
a m
a
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started