Q1) The only interface to the dictionary is this binary function? It would be very helpful to know if there are words in the dictionary with a given prefix. If the requirement is to find all words in the matrix, as you stated, there is not a better option than to loop over every string which can be formed from the matrix.
Q2) Use a state machine to match the string. If using strstr is a requirement, I'll call it once, after I find the string, just to meet that technicality. Don On Mar 30, 10:47 am, Decipher <ankurseth...@gmail.com> wrote: > This was asked from my friend in January for MTS profile. > > Q1) Given a matrix with letters in each square and you have to find words > which are there in the dictionary (like Children's Crosswords). You have > been given a function which outputs 1 if the given word is in the > dictionary. The word could be bidirectionally horizontal, vertical > or diagonal. Write an optimal algorithm for printing all such words. > > Q2) Given a very large string in which there is no kind of delimiter and > you have been given function strstr() . Find a given string in the larger > string using that function using minimum time and space. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.