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
Bumek [7]
3 years ago
10

Consider the recursive method whose definition appear below. Why? public static String mysteryString (String s){ if(s.length()==

1) return s; else return s.substring(s.length() – 1) + mysteryString(s.substring(0, s.length() – 1)); } What is the result of the following call?
System.out.println(mysteryString("computer"));
Computers and Technology
1 answer:
Marizza181 [45]3 years ago
6 0

Answer:

retupmoc

Explanation:

1.) Anwser will be retupmoc

because

public static String mysteryString(String s){

if(s.length() == 1){

return s;

}

else{

return s.substring(s.length() -1) + mysteryString(s.substring(0, s.length()-1));

}

}

In this program input is "computer" . So the function mysteryString(String s) it does

return s.substring(s.length() -1) + mysteryString(s.substring(0, s.length()-1));

so when it enters the first time ??s.substring(s.length() -1) and it will be give you 'r' then it calls the function recursively by reducing the string length by one . So next time it calls the mysteryString function with string "compute" and next time it calls return s.substring(s.length()-1)? + mysteryString(s.substring(0,s.length-1)) so this time it gives "e" and calls the function again recursively . It keeps on doing till it matched the base case.

so it returns "retupmoc".

You might be interested in
Jack is writing a paragraph for a school assignment. He proofreads his paper and notices that he used the word, "then" many time
Lynna [10]

He should use a Thesaurus.

5 0
3 years ago
Read 2 more answers
Which type of connection is needed to synchronize data with a cloud service?
Svetllana [295]

Answer:

Internet

Explanation:

The "Cloud" is an Online service this means it works on the Internet and without the Internet you can't have access to it.

7 0
3 years ago
4) Which is a more efficient way to determine the optimal number of multiplications in a matrix-chain multiplication problem: en
Assoli18 [71]

Answer:

Running RECURSIVE-MATRIX-CHAIN is asymptotically more efficient than enumerating all the ways of parenthesizing the product and computing the number of multiplications of each.

the running time complexity of enumerating all the ways of parenthesizing the product is n*P(n) while in case of RECURSIVE-MATRIX-CHAIN, all the internal nodes are run on all the internal nodes of the tree and it will also create overhead.

Explanation:

3 0
2 years ago
The general syntax to overload the stream extraction operator >> for a class is ____.
Aloiza [94]
Istream& operator>> (istream& input, Example& example)
{
// Extract your data from input stream here
return input;
}
5 0
3 years ago
Why can't we sign up to brainly.com??????????????????
LiRa [457]

Answer:

Explanation:

so why are you doing sign up

8 0
3 years ago
Other questions:
  • In Python, what kind of error is returned by the following code? (e.g. NameError, ValueError, IOError, etc.) def my_func(n1, n2)
    8·1 answer
  • Your game design company has recently asked all employees to use a specific personal information management application (PIM) to
    6·1 answer
  • Which app or website teaches java and phyton
    15·1 answer
  • Compute their Cartesian product, AxB of two lists. Each list has no more than 10 numbers.
    5·1 answer
  • Select the four bad password ideas.
    13·2 answers
  • Why do you usually find domain names instead of IP addresses in a URL? Select one: a. An IP address would make your web page loa
    11·1 answer
  • Consider the method get Hours, which is intended to calculate the number of hours that a vehicle takes to travel between two mil
    6·1 answer
  • A. All methods in an interface must be _________________ _________________________.
    5·1 answer
  • A(n) _____ exists when there are functional dependencies such that XY is functionally dependent on WZ, X is functionally depende
    14·2 answers
  • which of the following commands can be used to display any email messages awaiting delivery alongside the reason that they were
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!