Consider the following recursive method, which is intended to return a String with any consecutive duplicate characters removed. For example, removeDupChars("aabcccd") returns "abcd".public static String removeDupChars(String str){if (str == null || str.length() <= 1){return str;}else if (str.substring(0, 1).equals(str.substring(1, 2))){return removeDupChars(str.substring(1));}else{/* missing code */}}Which of the following can replace /* missing code */ so that removeDupChars works as intended?A. return removeDupChars(str.substring(2));B. return removeDupChars(str.substring(1)) + str.substring(0, 1);C. return removeDupChars(str.substring(2)) + str.substring(1, 2);D. return str.substring(0, 1) + removeDupChars(str.substring(1));E. return str.substring(1, 2) + removeDupChars(str.substring(2));

Answers

Answer 1

Answer:

D. return str.substring(0, 1) + removeDupChars(str.substring(1));

Explanation:

The logic here is following:

If the there are consecutive duplicate characters, return the removeDupChars method. The parameter of the removeDupChars method is a string, but the duplicate of the first character is removed from the string. The else-if part of the program does this job.

If the consecutive characters are not duplicated, return the first character of the string and the removeDupChars method. The parameter of the removeDupChars method is the rest of the string characters. The else part of the program does this job.

When the length of the str becomes one (or when the str is null), the program reaches its base and returns the str. The if part of the program does this job.

Answer 2

A recursive function is that function that calls itself from within.

The code statement that can replace the comment /* missing code */ is (d) return str.substring(0, 1) + removeDupChars(str.substring(1));  

The function definition is given as:

removeDupChars(String str)

The function has 3 linked conditional statements, each of which perform three different functions.

The first works for a null string and single characterThe second and the third are to return the intended string for strings with multiple lengths.

For the third condition to work, the consecutive characters must not be duplicated.

So, the code statement that does this is (d) return str.substring(0, 1) + removeDupChars(str.substring(1));

Read more about recursive functions at:

https://brainly.com/question/25647517


Related Questions

Create a text file named employee.dat containing the following data: b. Write a C++ program to read the employee.dat file created in Exercise 5a and produce a duplicate copy of the file named employee.bak.

Answers

Answer:

1000 500 250 125 the output

Explanation:

write a program using integers userNum and x as input,  userNum divided by

x four times.  EX : If  the input is 2000 2 the output is 1000 500 250 125

If your internet were to go out, what steps would you take to troubleshoot to restore your service?

Answers

Answer:

Make sure all your wires are connected and electricity is flowing

Turn your computer off and on

Turn your modem off and on

is it only your computer that can't connect or also your phone? (if it's only your computer then something in the configurations if off)

Call internet provider is non of these work.

Explanation:

Write a program that reads the lengths of the sides of a triangle from the user. Compute the area of the triangle using Heron's formula (below), in which s represents half of the perimeter of the triangle and a, b, and c represent the lengths of the three sides. Print rhe area to three decimal places.

Area= √ s(s-a)(s-b)(s-c)

Answers

Answer:

The java program is as follows.

import java.util.Scanner;

import java.lang.*;

public class Area

{

   //variables to hold the values

   static double a, b, c;

   static double s;

   static double area;

public static void main(String[] args) {

    //scanner class object created

    Scanner sc = new Scanner(System.in);

 System.out.print("Enter the first side: ");

 a=sc.nextInt();

 System.out.print("Enter the second side: ");

 b=sc.nextInt();

 System.out.print("Enter the third side: ");

 c=sc.nextInt();

 s=(a+b+c)/2;

 //function of Math class used

 area = Math.sqrt( s*(s-a)*(s-b)*(s-c) );

 //result displayed with 3 decimal places

 System.out.printf("The area of the triangle is %.3f", area);  

}

}

OUTPUT

Enter the first side: 1

Enter the second side: 1

Enter the third side: 1

The area of the triangle is 0.433

Explanation:

1. The variables to declare the three sides of the triangle, the semi-perimeter and the area of the triangle are declared with double datatype. All the variables are declared at class level and hence, declared with keyword, static.  

2. Inside main(), an object of the Scanner class is created.

Scanner sc = new Scanner(System.in);

3. Using the Scanner class object, user input is taken for all the three sides of the triangle.

4. Following this, the semi-perimeter is computed as shown.

s=(a+b+c)/2;

5. The area of the triangle is computed using the given formula which is implemented as shown.

area = Math.sqrt( s*(s-a)*(s-b)*(s-c) );

6. The sqrt() method of the Math class is used while computing the area of the triangle.

7. The area is displayed with three decimals. This is done using the printf() method as shown.

System.out.printf("The area of the triangle is %.3f", area);

8. The program is saved with the same name as the name of the class having the main() method.

9. The class having the main() method is always public.

You are currently working in a mid-tier accounting firm. In an engagement meeting with a client, the management of your client is concerned that the audit tests that you perform will disrupt operations. Your client has recently implemented a data warehouse and the management suggests that you draw the data for analytical reviews and substantive testing from the data warehouse instead of the operational database. The management points out that operational data are copied weekly into the data warehouse and all data you need are contained there. Outline your response to the management’s proposal and mention any concerns you might have. (maximum 300 words)

Answers

Answer:

The answer "Only when an auditor is free to perform his responsibilities should the audit contract be accepted. There should be no stress on an investigator but no independence".

Explanation:

In the essence of the data store, huge storage of the information, that is used to collect from either a variety of sources within the same company. The DTC  is often used as an analytics capability (OLAP frameworks) because a transfer can be focussed on the data structure. It's also currently easier for organizations to end things or assessment and determine the best information with full of data from one destination.

Create a complete warehouse:  It is unlikely, however, that each one of your getting your information at that same single place seems to be the greatest flexibility for providing a database server.  

Below are various benefits of providing data storage:  

Saving time:  In the company's ease of accessing data from different sources at the data center, that ensures no time to obtain information from other sources is lost. Higher trust: Its data is automatically moved into your data center in an ordered structure, rather than being replaced by human activity, as you'll be more sure that your information is nice and clean, complete and accurate.  Growing knowledge: In the data, the warehouse designs the information so that it can be easily analyzed.  Increasing quality: it would be far easier to manage individuals who reach your data whenever an association position is integrated. Data warehouse allows security fully flexible, allowing users to access all the systems and lock all of them.  

Following are its specific approach to creating a data center, which will you need to develop the core architecture in three sections:  

The stocking(storage) algorithm,  Software and working  HR.

Storage: it's the foundation of the structure and your warehouse lives there. The inner server is the client's office 's internal device as well as the cloud is an electronic storage solution that relies on external servers.

Software: It is a valuable method of private cloud architectural design. For two classes, centralization and visual imagery are commonly isolated.  

Human resources: It is the part of data warehouse operations which is extremely important for a workable example. To keep your warehouse running, you must use new circumstances in your company.

Design a program for Jones College. The current tuition is $12,000 per year, and tuition is expected to increase by 5 percent each year. Display the tuition amount for each year over the next five years (use a looping structure). Hint: You will need to use two assignment statements for calculating purposes. One will be an accumulating total assignment statement.

Answers

Answer:

current_tuition = 12000

for year in range(1, 6):

   increase_in_tuition = current_tuition * 0.05

   current_tuition += increase_in_tuition

   print("The tuition amount after " + str(year) + ".year: " + str(current_tuition))

Explanation:

*The code is in Python

Set the current tuition as 12000

Create a for loop that iterates 5 times

Inside the loop, calculate the increase in tuition. Add the increase in tuition value to the current tuition and print the current tuition.

Write a method called allDigitsOdd that returns whether every digit of a positive integer is odd. Return true if the number consists entirely of odd digits (1, 3, 5, 7, 9) and false if any of its digits are even (0, 2, 4, 6, 8). For example, the call allDigitsOdd(135319) returns true but allDigitsOdd(9145293) returns false.

Answers

Answer:

Sample output:

Enter integer 3232423

true

Enter integer 12131231

false

Explanation:

Above is the output of the program and for the solution check the screenshots attach to understand clearly the program.

Thanks

Bell LaPadula (BLP) is a security model
a) that can ensure the confidentiality of the classified data as well as its integrity
b) that can ensure the confidentiality of the classified data but not its integrity
c) that can ensure neither the confidentiality of the classified data nor its integrity
d) that can't ensure the confidentiality of the classified data but can its integrity

Answers

Answer:

Option (b) is the correct answer to this question.

Explanation:

BLP model can ensure classified data confidentiality, but it is not integrity. The Bell-LaPadula model is about secrecy. As just that, having read information would jeopardize privacy and security at a greater position than what has been permitted. The Bell – LaPadula Model (BLP) is a finite state model being used for political and police installations to implement authentication.

Other options are incorrect because they are not related to the given scenario.  

What will happen if registers are excluding the address register (Memory Address Register - MAR)?​

Answers

Answer: Memory address register captures and stores the memory address in CPU.

Explanation:

It stores the address of the data which is required to be sent and stored to specific location of the computer.It stores the next address of the data to be stored read or written.

If the memory address register is excluded in the system then the storage of memory will be compromised.

Computer has many functions. MAR is known to have the memory location of data that one needs to be accessed and if it is excluded, there is a compromise and one cannot get the data needed as it will be inaccessible.

What is the Memory Address Register?In a computer, the Memory Address Register (MAR) is known to be the CPU register that often stores the memory address through which one can get data to the CPU.

It is also known as the address to which data is often sent to or stored. That is, MAR has the power  to the memory location of data that one needs to be accessed.

Learn more about Memory Address Register from

https://brainly.com/question/24368373

why ‘illegal contract’ is a contradiction in terms?

Answers

Answer:

An Illegal contract or agreement is a contraction in terms when a contract is a legal obligation, illegal contract is viewed as a contradiction in terms.

Explanation:

Solution

An Illegal contract is called a contradiction for the following reasons listed below:

When a contract has a term that is obligatory, it is called a legal contract.

According to the rules of terms, when a contract is not done legally, it is considered an illegal contract.

On the common law of a contract or agreement, when a court does not apply or impose in any case or otherwise for a contract, it is seen as illegal.

Suppose we have a JDBC Connection object c to a database, and this database has a relation R (name, address, phone) Columns name and address are of string type, while phone is an integer. The following objects are also declare: Statement s-null; q = "SELECT address, phone FROM R" + "WHERE name = 'Bill Gates' ". ng Resultset r null; There are many methods that could be applied to the given variables. Whena method is applied to r, assume that it holds the result of query q. Then, identify a correct use of a method from the list below. oa) r s.executeQuery (q)i b) r-executeQuery(q) O) c) string a = r.ge t String (0); d) String x - r.getInt(1);

Answers

Answer:

The correct answer is option A r s.executeQuery (q) ;

Explanation:

Solution

The execute Query()  method is a method or technique derived from Statement class object. this type of method or techniques implements or executes  the SQL query and returns the table in the way of Result Set object.

The Option B, C, and the D in this case is not correct.

Industrial Products is a small light-manufacturing firm that produces a variety of control systems for heavy industry. It has a network that connects its office building and warehouse that has functioned well for the last year, but over the past week, users have begun to complain that the network is slow. Clarence Hung, the network manager, did a quick check of the number of orders over the past week and saw no real change, suggesting that there has been no major increase in network traffic. What would you suggest that Clarence do next?

Answers

Answer and Explanation:

The suggestions are as follows

1. There may be a faulty configuration that leads to packet losses, those packets lost are retransmitted over and over again that may have caused network slowing down.

2. The route or direction for the transmission of packets over the network can shift, which in effect increases the time for the transmission of packets and thus leads to a slowed-down network.

3. Probability is the authentication server that would take too much time to respond.

4. There may be some applications that produce errors for certain requests and therefore fail to complete the process on time. The failures may be on the front end of the server or back end.

Upgrading the apps to new versions will solve the issue, as the upgraded software involve different fixes.

5. Users will be tested on what they're doing on their devices. Unacceptable use of the network services can also result to a network slow- down.

6. Certain bad cable connexions or poor signal strength can result in network slowing down.

The data files from a computer-assisted questionnaire software program can be downloaded at the researcher's discretion; however, different formatting options, including SPSS-readable files, may not be available. Group of answer choices True False

Answers

Answer:

False.

Explanation:

When data files are sourced from a computer-assisted questionnaire software program. The data files can be downloaded at the researcher's discretion, different formatting options can be used on the data files, and SPSS (Statistical Product and Service Solutions)-readable files are also available.

For instance, the CAPI (Computer-Assisted Personal Interview), CAWI (Computer-Assisted Web Interview)  and CASI (Computer-Assisted Self Interview) software program collects data from potential targeted population in a survey. These data can be downloaded by the originator of the survey with its SPSS (Statistical Product and Service Solutions)-readable files.

Also, if the researcher wishes to edit or format the data, it is very possible to achieve.

A cookie recipe calls for the following ingredients: • 1.5 cups of sugar • 1 cup of butter • 2.75 cups of flour The recipe produces 48 cookies with this amount of ingredients. Write a program that asks the user how many cookies they want to make and then displays the number of cups of each ingredient needed for the specified number of cookies in the following format: You need 5 cups of sugar, 3 cups of butter, and 7 cups of flour. Note: Don’t worry about formatting the numbers in the output.

Answers

Answer:

This program is written using c++ programming language

Comments are used to explain difficult lines

See attachment for .cpp source files

Program starts here

#include<iostream>

using namespace std;

int main()

{

// Calculate number of ingredient that makes up 48 cookies

float num_sugar = 1.5/48;

float num_butter =1.0/48;

float num_flour = 2.75/48;

//Declare integer variable to get number of cookies from user

int n;

// Prompt user for number of cookies needed

cout<<"Enter number of cookies: ";

cin>>n;

// Calculate equivalent amount of ingredient

num_sugar *= n;

num_butter *= n;

num_flour *= n;

// Display Result

cout<<"You need "<<num_sugar<<" cups of sugar, "<<num_butter<<" cups of butter, and "<<num_flour<<" cups of flour.";

return 0;

}

//End of Program

Discuss whether this is a good Web site to use as a source for reliable, academically sound information on neurotransmitters. Why or why not?

Based on what you have learned about neurotransmitters in this unit through the textbook and intellipath, do you think you would recommend a friend or family member opt for this testing? Explain your response.

Answers

Answer:

The answer to this question can be described as follows:

Explanation:

No, for all of this experiment, I will not remember a family member or friend. It is because the test results and arguments presented in it were not as relevant and fun.  

After all, they should be. They will often seem vague and uninteresting to make this same testing perception boring and tedious overall. In the above line, it is explained, that why they are not is used, that's why the answer to this question is no.
Other Questions
state of the triangles in each pair are similar. If so State how you know they are similar and complete the similarity statement. Part 2 Consider two bonds, a 3-year bond paying an annual coupon of 5.90% and a 10-year bond also with an annual coupon of 5.90%. Both currently sell at a face value of $1,000. Now suppose interest rates rise to 9%. a. What is the new price of the 3-year bonds Add 3 5/12 + 2 5/9 . Simplify the answer and write as a mixed number. Choose the word or phrase that best defines the italicized word"Soon he had left the cultivated part of the farm."prepared for burningprepared for harvestprepared for plantingprepared for sale Which of the best following summarizes Trends in American literature and music in the 1920s What happened in 632? A Muhammad heard the voice of God, or Allah in Arabic, speaking to him and began spreading Islam. B Muhammad died. C An Italian mathematician brought the Arabic numerals to Europe. D Babur founded the Mughal Empire. It is usually assumed that an action potential begins immediately at the cathode. If this were true, both methods for calculating conduction velocity would provide the same answer. However, when a strong stimulus intensity is used, the action potential may begin some distance away from the cathode. Under these conditions, the difference method would be more accurate.Did you observe any important difference between the conduction velocity values? A student caries out an experiment and dissolves 10.0 g of sodium bromide. NaBr, in 200g of water. What is the molality of the solution? To lift fingerprints from a crime scene, a solution of silver nitrate is sprayed on a surface to react with the sodium chloride left behind by perspiration. What is the molarity of a silver nitrate solution if 42.8 mL of it reacts with excess sodium chloride to produce 0.148g of precipitate according to the following reaction? AgNO3(aq)+NaCl(aq) --> AgCl(s)+NaNO3(aq) A) 2.41 x 10^-2 M B) 0.0229 M C) 6.66 x 10^-2 M D) 3.2 x 10^-3 M E) 2.29 x 10^2 M 1. If x + 13 = 5, then the value of x is(a) 18(b)-18(c)-8(d) 8 AB is perpendicular to CD. How many 90 angles are formed by the intersection? Please help! Correct answer only, please! The cafeteria manager at a middle school wanted to keep track of how many student breakfast and lunches were sold on a Monday. A. B. C. D. one more last one help What are the opposites of 9, 3.6, 2.25, and 9 1 2 ? Enter the answers in respective order, each separated by comma. 1. a) Write in standard form:i) 2 470 000 What factor makes the Hawaiian Islands the perfect place for plant species to diversify? given that 10 - 18 2 = a + b 2 where a and b are integers.Find the values of a and b. Luis wrote a check of $100 to the electricity company. After a few days he received If your customers are satisfied 11 out of 15 times how many are satisfied If 350 people come in on Black Friday Shakespeares historical plays dramatize the lives of English rulers during the Medieval era. Why are these plays not always historically accurate?