Question: Data Structure , Language JAVA Q1. Write a recursion method findWord(), which takes two Strings as parameters. The first string is a sentence, and the

 Data Structure , Language JAVA Q1. Write a recursion method findWord(),

Data Structure , Language JAVA

Q1. Write a recursion method findWord(), which takes two Strings as parameters. The first string is a sentence, and the second string is a word. The method should search the sentence for the given word. It returns true if the word was found, and false otherwise. The method should be written recursively. You can use the substring() method to help you parse the sentence. For example: int i = x.indexOf(' '); //we will look for a space to identify words String word = x.substring(0, i); //returns the first string before the space String rest = x.substring(i); //returns the rest of the string Write a main with a test code to show how your method works. What is the time complexity of your method? Assuming 0(1) time complexity for substring() method

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!