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
alukav5142 [94]
3 years ago
12

Let’s define a new language called dog-ish. A word is in the lan- guage dog-ish if the word contains the letters ’d’, ’o’, ’g’ a

re in the word in order. For example, "dpoags" would be in dog-ish because dpoags. Other words like "dog", "doooooog", "pdpopgp", and "qwqwedqweqweoqweqw- gasd" would be in dog-ish. "cat", "apple", "do", "g", would not be in dog-ish.
(a) (20 points) Define the method inDogish recursively such that it re- turns true if the word is in dog-ish and false if it is not. I left a dogishHelper 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.

class Main {public static void main(String[] args) {/* leave this main method blank but feel free to uncomment below linesto test your code */// System.out.println(dogish("aplderogad"));// System.out.println(dogishGeneralized("aplderogad", "dog"));} // returns true if the word is in dog-ish// returns false if word is not in dog-ishpublic static boolean inDogish(String word){return false;} // necessary to implement inDogish recursivelypublic static boolean dogishHelper(String word, char letter) {return false;} // a generalized version of the inDogish methodpublic static boolean inXish(String word, String x){return false;}}

Engineering
1 answer:
attashe74 [19]3 years ago
5 0

Answer and Explanation:

// code

class Main {

   public static void main(String[] args) {

       /*

        *

        *

        * your code

        *

        */

       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) {

       // first find d

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

           // first find string after d

           String temp = word.substring(word.indexOf("d"));

           // find o

           if (dogishHelper(temp, 'o')) {

               // find string after o

               temp = temp.substring(temp.indexOf("o"));

               // find g

               if (dogishHelper(temp, 'g'))

                   return true;

           }

The output is attached below

       }

       return false;

   }

   // necessary to implement inDogish recursively

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

       // end of string

       if (word.length() == 0)

           return false;

       // letter found

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

           return true;

       // search in next index

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

   }

   // a generalized version of the inDogish method

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

       if (x.length() == 0)

           return true;

       if (word.length() == 0)

           return false;

       if (word.charAt(0) == x.charAt(0))

           return inXish(word.substring(1), x.substring(1));

       return inXish(word.substring(1), x.substring(0));

   }

}

PS E:\fixer> java Main true true ne on

PS E:\fixer> java Main true true ne on

You might be interested in
A system consists of N very weakly interacting particles at a temperature T sufficiently high so that classical statistical mech
algol [13]

Answer:

the restoring force is = 3/4NKT

Explanation:

check the attached files for answer.

7 0
3 years ago
In RSA Digital Signature, Suppose Bob wants to send a signed message (x = 4) to Alice. The first steps are exactly t eps are exa
Luda [366]

Answer:

what r u on

Explanation:

4 0
3 years ago
How many robots does bailey nursery own ​
givi [52]

Answer:

The Bailey family has flourished during its business’ 110-year history. But Bailey Nurseries’ leaders still operate with the belief that the family doesn’t always know best. The company has grown from a one-man operation selling fruit trees and ornamental shrubs to one of the largest wholesale nurseries in the United States, thanks to insights from those who are family and those who aren’t.

“For a business to thrive, you have to ask for outside help,” says Terri McEnaney, president of the Newport-based company and a fourth-generation family member. “We get an outside perspective through family business programs, advisors and our board, because you can get a bit ingrained in your own way of thinking.”

When Bailey Nurseries chose its current leader in 2000, it brought in a facilitator who gathered insights from key employees, board members and owners. Third-generation leaders (and brothers) Gordie and Rod Bailey picked Rod’s daughter McEnaney, who had experience both inside and outside the company.

Explanation:

5 0
2 years ago
N DevOps, high levels of automation are expected, which increases productivity. Which fact illustrates this productivity increas
Bess [88]

Answer:

Less intervention of humans.

Explanation:

This fact illustrate that less intervention of human in the production is the main cause for increase in productivity because use of machinery completed the work in less time as compared to the use of human labour. In many industries, machines takes the place of humans which increases the production of products but at the same time, increase the unemployment rate in the society. Making the whole industry on automation can increase the productivity of products in less time.

3 0
3 years ago
A monatomic ideal gas undergoes a quasi-static process that is described by the function p(????)=p1+3(????−????1) , where the st
Alenkasestr [34]

A pure gas made up only of atoms. The noble gases argon, krypton, and xenon are some examples.

Concepts:

Perfect gas law: Work performed on the system: PV = nRT W = -∫PdV

Energy preservation formula: U = Q + W

Reasoning:

W = nRT ln(Vi/Vf) when the process is isothermal.

The temperature is said to be constant, and we are given n, Pfinal, and Vfinal.

Calculation information:

(A) A process that is isothermal has a constant temperature.

PV = nRT, and hence, constant

nRT = PV = 101000 Pa*25*10-3 m3

For a process that is isothermal, W = nRT ln(Vi/Vf).

W/(nRT)=3000 J/(101000 Pa*25*10-3 m3)=-1.19

(The gas produces -W of labor.)

Vi = (25*10-3 m3)/3.28 = 7.62*10-3 m3 = 7.62 L where Vf/Vi = exp(1.19) = 3.28 Vi (b) for a perfect gas PV = nRT. 101000 Pa*25*10-3 m3 = (8.31 J/K) T. T = 303.85 K.

To know more about process click here:

brainly.com/question/29310303

#SPJ4

5 0
1 year ago
Other questions:
  • A PV battery system has an end-to-end efficiency of 77%. The system is used to run an all-AC load that is run only at night. The
    11·1 answer
  • Consider a vortex filament of strength in the shape of a closed circular loop of radius R. Obtain an expression for the velocity
    10·1 answer
  • Nearlyof all serious occupational injuries and illnesses stem from overexertion of repetitive motion.
    14·1 answer
  • To test the effects of a new fertilizer, 100 plots were divided in half. Fertilizer A is randomly applied to one half, and B to
    13·2 answers
  • What are some "vital signs" that we consider to tell us about the economy?
    12·2 answers
  • Pleaseeee help me with this!!
    10·1 answer
  • 7–2 Cooling of a Hot Block by Forced Air at High
    6·1 answer
  • Technician A says that fuel filler caps with pressure and vacuum vents are used with EVAP system fuel tanks. Technician B says t
    5·1 answer
  • Explain how to properly engage the safety latches on the Stan Design Pit Jack.
    10·1 answer
  • Technician a s ays a shorted circuit can generate excessive heat. technician b says a shorted circuit will cause the circuit pro
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!