answer.
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
ladessa [460]
2 years ago
10

Write a recursive method called isReverse that accepts two strings as parameters and returns true if the two strings contain the

same sequence of characters as each other but in the opposite order (ignoring capitalization), and false otherwise. For example, the call of isReverse("hello", "eLLoH") would return true. The empty string, as well as any one-letter string, is considered to be its own reverse
Computers and Technology
1 answer:
Virty [35]2 years ago
3 0

Answer:

public static boolean isReverse(String s1, String s2)

{

if (s1.length() == 0 && s2.length() == 0)

{

return true;

}

else if (s1.length() == 0 || s2.length() == 0)

{

return false;

} else

{

String s1first = s1.substring(0, 1);

String s2last = s2.substring(s2.length() - 1);

return s1first.equalsIgnoreCase(s2last) &&

isReverse(s1.substring(1), s2.substring(0, s2.length() - 1));

}

}

public static boolean isReverse(String s1, String s2)

{

if (s1.length() != s2.length()) {

return false; // not same length

} else if (s1.length() == 0 && s2.length() == 0) {

return true;

} else

{

s1 = s1.toLowerCase();

s2 = s2.toLowerCase();

return s1.charAt(0) == s2.charAt(s2.length() - 1) &&

isReverse(s1.substring(1, s1.length()),

s2.substring(0, s2.length() - 1));

}

}

public static boolean isReverse(String s1, String s2)

{

if (s1.length() == s2.length())

{

return isReverse(s1.toLowerCase(), 0, s2.toLowerCase(), s2.length() - 1);

} else {

return false;

// not same length

}

}

private static boolean isReverse(String s1, int i1, String s2, int i2)

{

if (i1 >= s1.length() && i2 < 0) {

return true;

} else {

return s1.charAt(i1) == s2.charAt(i2) &&

isReverse(s1, i1 + 1, s2, i2 - 1);

}

}

public static boolean isReverse(String s1, String s2)

{

return reverse(s1.toLowerCase()).equals(s2.toLowerCase());

}

private static String reverse(String s)

{

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

return s;

} else {

return reverse(s.substring(1)) + s.charAt(0);

}

}

Explanation:

You might be interested in
Marissa works at a company that makes perfume. She noticed many samples of the perfume were not passing inspection. She conducte
garik1379 [7]
Writing a business letter as if she gets her point across to the head of department then he could change the way they made the perfume so they would pass inspection and standard.
6 0
2 years ago
Read 2 more answers
What is one major structural difference between a decision structure (such as a decoder) and a storage structure (such as an RS
Andrej [43]

Answer:

B. The storage structure requires a clock input.

Explanation:

Logic circuits are circuits in electronics that give output based on the logic gate principle and its inputs. It can be a sequential logic circuit or a combinational logic circuit.

Decoders RS latches are combinational logic circuits because they both comprise of a combination of several sequential circuits to make their systems. The difference between decoders and RS latches is that the RS is a storage structure which is made up of flip-flops which require a clock input

8 0
2 years ago
When you complete a form online with your name, address, and credit card information in order to make a purchase, you are giving
mafiozo [28]

Answer:

Structured

Explanation:

A data dictionary can be defined as a centralized collection of information on a specific data such as attributes, names, fields and definitions that are being used in a computer database system.

In a data dictionary, data elements are combined into records, which are meaningful combinations of data elements that are included in data flows or retained in data stores.

This ultimately implies that, a data dictionary found in a computer database system typically contains the records about all the data elements (objects) such as data relationships with other elements, ownership, type, size, primary keys etc. These records are stored and communicated to other data user when required or needed.

A relational database can be defined as a type of database that is structured in a manner that there exists a relationship between its elements.

Hence, when a user completes a form online by providing his or her name, address, and credit card information in order to make a purchase, he or she is giving the company structured data (pre-defined and formatted to a set structure) that can be used to make up (populate) a relational database or spreadsheet.

A spreadsheet can be defined as a file or document which comprises of cells in a tabulated format (rows and columns) typically used for formatting, arranging, analyzing, storing, calculating and sorting data on computer systems.

3 0
2 years ago
A contact list is a place where you can store a specific contact with other associated information such as a phone number, email
Arte-miy333 [17]

Answer:

# The user in prompted for input and stored in userInput

userInput = str(input("Enter the contact: "))

# The user input is splitted and stored in splitUserInput

# splitUserInput is a list because split returns a list

splitUserInput = userInput.split(" ")

# The user is prompt to enter the search contact

# The search contact will have the first letter capitalize

# should it be entered in lower case all through

searchContact = str(input("Enter the search contact: "))

# loop through the list

for i in range(len(splitUserInput)):

   # compare if the string at any value of i

   # is the same as the searchContact

   # we display the string ahead of it

   # by adding 1 to the index

   if(splitUserInput[i] == searchContact):

       print(splitUserInput[i + 1])

Explanation:

A sample screenshot is attached. The code is written in Python 3 and well commented.

The program prompt the user for input then split the input into a list. It then asked for a contact to search for. It begins looping through the list, if the search contact is found at any index, then it prints what is in front of the index.

5 0
2 years ago
) A byte is used to represent a single character in the computer ______<br> true or false?
sdas [7]
Answer: false
Explanation:
7 0
2 years ago
Read 2 more answers
Other questions:
  • Which of the following people is required by law to wear a seat belt? A. The operator of a truck weighing more than 26,000 lbs B
    15·1 answer
  • In the game of $Mindmaster$, secret codes are created by placing pegs of any of seven different colors into four slots. Colors m
    5·1 answer
  • The icacls.exe command adds __________, which are visible by clicking the Advanced button in the folder Properties dialog box
    15·1 answer
  • You are consulting for a trucking company that does a large amount ofbusiness shipping packages between New York and Boston. The
    5·1 answer
  • A ____ is a software implementation of a computer that executes programs as if it were a real physical computer within the physi
    15·1 answer
  • Information is stored on a compact disk in a coded pattern of tiny pits arranged in a track that spirals outward toward the rim
    6·1 answer
  • Suppose that we have a set of activities to schedule among a large number of lecture halls, where any activity can take place in
    8·1 answer
  • 1.1.5 practice: analyzing business culture
    13·1 answer
  • A large number of genetic codes are stored as binary values in a list. Which one of the following conditions must be true in ord
    5·2 answers
  • The height of a small rocket y can be calculated as a function of time after blastoff with the following piecewise function: y 5
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!