1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Dahasolnce [82]
4 years ago
14

a) (20 points) Define the method inDogish recursively such that it returns true if the word is in dog-ish and false if it is not

. I left a dogish Helper method, which I guarantee you will need to recursively solve dogish. An iterative solution will receive no points. (b) (20 points) Define the method inXish that does the same logic of dog-ish but for some word X. The method returns true if the word contains all the letters in the word X. The solution must be recursive. An iterative solution will receive no points.
Computers and Technology
1 answer:
tia_tia [17]4 years ago
7 0

Answer:

/ Main.java

class Main {

     public static void main(String[] args) {

           //System.out.println(inDogish("aplderogad"));

           //System.out.println(inXish("aplderogad", "dog"));

     }

     // returns true if the word is in dog-ish

     // returns false if word is not in dog-ish

     public static boolean inDogish(String word) {

           /**

           * Note: we can use the inXish() method to complete this method in a

           * single line if you want. just write 'return inXish(word,"dog");' and

           * you are done.

           */

           // if word is null or empty, returning false

           if (word == null || word.length() == 0) {

                 return false;

           }

           // converting word to lower case

           word = word.toLowerCase();

           // if 'd' does not exist on the word, returning false

           if (!dogishHelper(word, 'd')) {

                 return false;

           }

           // removing the characters upto first 'd' in word

           word = word.substring(word.indexOf('d') + 1);

           // if 'o' does not exist on the word, returning false

           if (!dogishHelper(word, 'o')) {

                 return false;

           }

           // removing the characters upto first 'o' in word

           word = word.substring(word.indexOf('o') + 1);

           // if 'g' does not exist on the word, returning false, otherwise

           // returning true

           if (!dogishHelper(word, 'g')) {

                 return false;

           } else {

                 return true;

           }

     }

     // necessary to implement inDogish recursively.

     // returns true if letter is in word, else not.

     public static boolean dogishHelper(String word, char letter) {

           // if word is empty, returning -1

           if (word == null || word.length() == 0) {

                 return false;

           }

           // if first character in word is letter, returning 0

           if (word.charAt(0) == letter) {

                 return true;

           }

           return dogishHelper(word.substring(1), letter);

     }

     // the best thing about the above helper method is that we can use it in

     // inXish method also

     // a generalized version of the inDogish method

     public static boolean inXish(String word, String x) {

           // if x is empty, returning true (base case, which means all the letters

           // in x are in word in that order)

           if (x.length() == 0) {

                 return true;

           }

           // getting first character of x

           char first = x.charAt(0);

           // if first character does not exist on the word, returning false

           if (!dogishHelper(word, first)) {

                 return false;

           }

           // calling and returning inXish recursively, passing the word after

           // removing characters upto first occurrance of char first, and x after

           // removing first character from it

           return inXish(word.substring(word.indexOf(first) + 1), x.substring(1));

     }

}

Explanation:

You might be interested in
(PLEASE HELP!! I'll award brainiest!!)
Bas_tet [7]

Answer:

Repair

Have a good day

3 0
3 years ago
Read 2 more answers
When a module is processed:
a_sh-v [17]

Answer:

B. The computer jumps to the module, executes the instructions in the module, and then returns to the next executable instruction.

Explanation:

A software development life cycle (SDLC) can be defined as a strategic process or methodology that defines the key steps or stages for creating and implementing high quality software applications.

A module can be defined as a separate software component or unit of a hardware program that comprises of one or more repeatable functions (tasks). A module is portable and as such can be used in various software applications or systems through a programming interface. Also, they are interoperable because they are generally compatible with various components of a software application or system.

When a module is processed, the computer jumps to the module, executes the instructions in the module, and then returns to the next executable instruction.

This ultimately implies that, the execution of an instruction by a computer is done sequentially and once the task is completed, the computer moves to the next executable instruction or command.

3 0
3 years ago
What are QBASIC Operators ?​
Anna35 [415]

Answer: There are four types of operators in QBASIC. They are Arithmetic Operators, Relational Operators, Logical Operators and Sting Operator. a. Arithmetic Operators. Arithmetic Operators are used to perform mathematical calculations like addition, subtraction, division, multiplication and exponential. :)

5 0
4 years ago
Read 2 more answers
Which component of cpu controls the overall operation of computer..​
arsen [322]

Answer:

Control Unit.

Explanation:

The component of CPU that controls the overall operation of computer is control unit.

The control unit, also known as CU, is one of the main component of the Central Processing Unit (CPU). The function of CU is to fetch and instruct computer's logic unit, memory, input and output device. The CU receives information which it turns into signals. Thus controlling the overall operations of computer.

Therefore, control unit is the correct answer.

4 0
3 years ago
When is blue for when the instance in which the directory of compulsion in the air!
KATRIN_1 [288]
I think it’s what the other person said
7 0
3 years ago
Other questions:
  • ( answer goes here) are pictures that you can click on to tell your computer what to do.
    10·2 answers
  • Write the equivalent c++ expression for the following algebraic expressions
    11·1 answer
  • Q.No.3. A filling station (gas station) is to be set up for fully automated operation. Drivers swipe their credit card through a
    10·1 answer
  • Joining strings together is known as?
    7·1 answer
  • 1.<br> The correct way to use a seat belt is
    8·1 answer
  • What does the word "e-business" mean?
    11·2 answers
  • Consider a Dog class and a Mammal class. Which is true? Group of answer choices The Dog class is abstract The Mammal class is co
    10·1 answer
  • Why would a user want to resend a message? Check all that apply.
    7·2 answers
  • write the implementation (.cpp file) of the gastank class of the previous exercise. the full specifiction of the class is:
    10·1 answer
  • a network administrator for a large oil company has discovered that a host on the company network has been compromised by an att
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!