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
artcher [175]
3 years ago
12

Write a static method called split that takes an ArrayList of integer values as a parameter and that replaces each value in the

list with a pair of values, each half the original. If a number in the original list is odd, then the first number in the new pair should be one higher than the second so that the sum equals the original number. For example, if a variable called list stores this sequence of values:
Computers and Technology
1 answer:
lorasvet [3.4K]3 years ago
5 0

Answer:

The method is as follows:

public static void split(ArrayList<Integer> mylist) {

   System.out.print("Before Split: ");

   for (int elem = 0; elem < mylist.size(); elem++) { System.out.print(mylist.get(elem) + ", ");    }

   System.out.println();

   for (int elem = 0; elem < mylist.size(); elem+=2) {

       int val = mylist.get(elem);

       int right = val / 2;

       int left = right;

       if (val % 2 != 0) {            left++;        }

       mylist.add(elem, left);

       mylist.set(elem + 1, right);    }        

   System.out.print("After Split: ");

   for (int elem = 0; elem < mylist.size(); elem++) { System.out.print(mylist.get(elem) + ", ");    }

}

Explanation:

This declares the method

public static void split(ArrayList<Integer> mylist) {

This prints the arraylist before split

<em>    System.out.print("Before Split: "); </em>

<em>    for (int elem = 0; elem < mylist.size(); elem++) { System.out.print(mylist.get(elem) + ", ");    } </em>

<em>    System.out.println(); </em>

This iterates through the list

   for (int elem = 0; elem < mylist.size(); elem+=2) {

This gets the current list element

       int val = mylist.get(elem);

This gets the right and left element

<em>        int right = val / 2; </em>

<em>        int left = right; </em>

If the list element is odd, this increases the list element by 1

       if (val % 2 != 0) {            left++;        }

This adds the two numbers to the list

       mylist.add(elem, left);

       mylist.set(elem + 1, right);    }      

<em>This prints the arraylist after split</em><em> </em>

<em>    System.out.print("After Split: "); </em>

<em>    for (int elem = 0; elem < mylist.size(); elem++) { System.out.print(mylist.get(elem) + ", ");    } </em>

<em>}</em>

You might be interested in
What is data mining?1) A particular attribute of information 2) The common term for the representation of multidimensional infor
tiny-mole [99]

Answer:

option 4)

Explanation:

  • Data mining is characterized as a procedure used to extricate usable information from a bigger arrangement of any crude data. It suggests breaking down information designs in huge groups of data utilizing at least one programming.  
  • Data mining is utilized to find patterns and connections in the information so as to help settle on better business choices.  
  • Information or data mining can help spot deals patterns, create more astute advertising efforts, and precisely foresee client faithfulness.
3 0
3 years ago
What is an example of an intelligent automation solution that makes use of artificial intelligence?.
mafiozo [28]

Copying text from a web browser is an example of an intelligent automation solution that uses artificial intelligence.

<h3>What is  intelligent automation solution?</h3>

The intelligent automation solution is the combination of new technologies such as artificial intelligence and robotic automations that helps to enhance and enable the program to learn, interpret, and respond by itself.

The complete questions is as follows:

  1. signing-in to various desktop applications
  2. filling out forms with basic contact information
  3. copying text from a web browser
  4. recognizing and interpreting natural language

The best example for  intelligent automation solution is copying text from web browser as the AI interprets the command and the robotic automation will provide its output.

Therefore, option 3. is correct.

Learn more about intelligent automation solution, here:

brainly.com/question/24977867

#SPJ1

7 0
2 years ago
You can use a server-side script as a ____ to access data from another domain.
Mashcka [7]
I believe the answer your looking for is "Proxy"
0 0
3 years ago
Perform algorithm time measurement for all three quadratic sorting algorithms for Best Case (already sorted), Average Case (rand
Kaylis [27]

Answer:

Experiment size : 50,000

==================================

Selection sort :

---------------------------------------------------------

Worst case : 0.162

Average case : 0.116

Best case : 0.080

Insertion sort :

---------------------------------------------------------

Worst case : 0.162

Average case : 0.116

Best case : 0.080

Bubble sort:

--------------------------------------------------------

Worst case : 0.211

Average case : 0.154

Best case : 0.117

Experiment size : 100,000

==================================

Selection sort :

---------------------------------------------------------

Worst case : 0.316

Average case : 0.317

Best case : 0.316

Insertion sort :

---------------------------------------------------------

Worst case : 0.316

Average case : 0.317

Best case : 0.316

Bubble sort:

--------------------------------------------------------

Worst case : 0.482

Average case: 0.487

Best case : 0.480.

Experiment size : 200,000

==================================

Selection sort :

---------------------------------------------------------

Worst case : 1.254

Average case : 1.246

Best case : 1.259

Insertion sort :

---------------------------------------------------------

Worst case : 1.254

Average case : 1.246

Best case : 1.259

Bubble sort:

--------------------------------------------------------

Worst case : 1.990

Average case : 2.009.

Best case : 1.950

Explanation:

[NB: since it is very long there is the need for me to put it it a document form. Kindly check the doc. Files. The file A is the sort Analysis.Java file and the file B is the sort.Java file].

The concept of algorithm time measurement strictly depends on the following;

=> The measurement of time, space or energy on different sizes.

=> Plotting of the measurements and characterizing them.

=> Running or implementation of the algorithm.

Programming language such as Java can be used in accessing the operating system clock and Java had two static methods.

KINDLY CHECK BELOW FOR THE ATTACHMENT.

Download doc
<span class="sg-text sg-text--link sg-text--bold sg-text--link-disabled sg-text--blue-dark"> doc </span>
<span class="sg-text sg-text--link sg-text--bold sg-text--link-disabled sg-text--blue-dark"> doc </span>
5 0
3 years ago
Let U = {b1, b2, , bn} with n ≥ 3. Interpret the following algorithm in the context of urn problems. for i is in {1, 2, , n} do
viva [34]

Answer:

Check the explanation

Explanation:

Kindly check the attached image for the first step

Note that the -print" statement executes n(n — I)(n — 2) times and the index values for i, j, and k can never be the same.  

Therefore, the algorithm prints out all the possible ways to draw three balls in sequence, without replacement.

Now we need to determine the number of lines this the algorithm print. In this case, we are selecting three different balls randomly from a set of n balls. So, this involves permutation.  

Therefore, the algorithm prints the total  

P(n, 3)  

lines.  

7 0
3 years ago
Other questions:
  • Describe a situation involving making a copy of a computer program or an entertainment file of some sort for which you think it
    7·1 answer
  • Leah wants to create a PowerPoint presentation for a history report about the progressive era in the 1900s. To
    6·2 answers
  • The domains of the risk IT framework mutually inform each other, creating flexibility and agility. It is possible to uncover a p
    10·1 answer
  • When using a search engine, what is the name of a word or phrase somebody types to find something online?
    12·2 answers
  • David Doe is a network administrator for the ABC Company. David is passed over for promotion three times. He is quite vocal in h
    14·1 answer
  • What is the exposition of the movie inside out
    13·2 answers
  • Hey guys!
    5·2 answers
  • What a promblem Hypothesis<br>​
    8·2 answers
  • Write a loop that continually asks the user what pets the user has until the user enters rock in which case the loop ends. It sh
    6·1 answer
  • According to the test for x-ray film freshness, the film is fresh and has been properly stored and handled when the processed fi
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!