Question: 1 . Searching horizontally. First , consider the problem of finding words horizontally in the grid going from left to right. Consider the first row
Searching horizontally.First consider the problem of finding words horizontally in the grid going from left to right. Consider the first row in the example shown above:y c o d e jNotice that this row contains the wordscodcode andode Suppose that the row is represented as the listy c o d e j A simple way to explore all the possible words going L to R in this list would be as follows the process for the other rows is similar Starting at the first element ie y check whether the sequence of length starting at that position is a legal word we start with length because a legal word has to be at least three letters long Then check for length then for length etc., until you reach the end of the list. Now repeat this step, but starting at the second element ie c Notice that this time you will come to the end of the list one step sooner. Then repeat for the third element, and so on In each of these steps, your code is checking a sequence of list elements eg the sequence of elements c o d e to see whether this is a word that occurs in your list of words. How can you use the functionconcatlistfrom the Short Problems for this assignment? Next consider the problem of searching for words horizontally going right to left. Suppose we want to search the row y c o d e j going right to left. This is actually the same as reversing the row, toj e d o c yand then searching left to right a problem youve solved already The key thing to note here is that youve taken the problem of searching RtoL and converted it into an equivalent problem involving an LtoR search, for which youve already written code.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
