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
How can users create a shortcut to favorite websites and store them in their browser?
8090 [49]
I know the first one is A) Bookmark sites and I think the second one is B) Cross-platform capability. 
8 0
3 years ago
Read 2 more answers
Is the computer a device that calculates and has the independence and initiative for the actions it performs?
inna [77]

Answer:

The answer is "True".

Explanation:

In this question, the given statement is true because the computer is a device that receives information as input, analyzes information utilizing a program that provides relevant information for the processed data, and in this, it performs numerous calculation and all the calculation will be store in its memory, which is used in the future for collect data on hard drives.

8 0
3 years ago
Using the XML Document below (library with books), define the following queries in XQuery: (a) Give the titles of all Books sort
Softa [21]

Answer:

Explanation:

a)use order by clause for sorting

for $x in doc("books.xml")/bib/book order by xs:float($x/price) return $x/title (default sorted in ascending order)

or

for $x in doc("books.xml")/bib/book order by xs:float($b/price) descending  return $b/title (sorted in descending order)

b)doc("books.xml")//book[author = 'Abiteboul']

c)for $x in distinct-values(doc("bib.xml")/bib/book/author)

return <res>

<name>{$x}</name>

<count>

 {count (doc("bib.xml")//book[exists(indexof(author,$x))]) }

</count>

<res>

3 0
3 years ago
Which of the following refers to semitransparent text or a faint object that appears
Agata [3.3K]
<h2>Option D: Watermark refers to semitransparent text or a faint object that appears behind the document content.</h2>

Explanation:

Footer: This is a text which appears in the bottom of every page. Mostly page numbers and the name of the publisher or the company name will be in the footer.

Page Color: This represents the color of the page

Page border: This option provides border to the page. The border can be thin or thick according to the requirement.

Watermark: This is the right answer. A watermark is added such that your content cannot be used by anyone else without permission. When you copy the text, the water mark also gets copied, thus avoiding plagiarism.

4 0
3 years ago
What is security in Technology<br>​
maria [59]

Answer:

IT security is a set of cyber security strategies that prevents unauthorized access to organizational assets such as computers, networks, and data.

3 0
3 years ago
Read 2 more answers
Other questions:
  • HELP ASAP????? please
    5·2 answers
  • ____ documents consist of the text to be displayed on a Web page, together with a number of special characters: tags that achiev
    14·1 answer
  • There is an enormous amount of information on the Internet that is automatically separated into good content and not-so-good con
    15·1 answer
  • Choose all the answers that apply.
    15·1 answer
  • Java: which expression is evaluated first
    13·1 answer
  • What does “human-like” mean when we are talking about a machine?
    7·1 answer
  • ANSWER ASAP!!!!!
    10·2 answers
  • You are given a 5-letter word (for example, abcde). Write a C-Program which outputs all possible unique 5 letter permutations of
    13·1 answer
  • Reflection about information technology​
    11·1 answer
  • Enabling encryption of all data on a desktop or laptop computer is generally considered:______.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!