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
Nonamiya [84]
3 years ago
12

Write the following method that merges two sorted arrays into a new sorted array public static int [] merge(int [] array1, int [

] array2) { // add your code here } public static void main(String [] args) { int [] array1 = {1, 5, 16, 61, 111}; int [] array 2 = {2, 4, 5, 6} int [] mergedArray = merge(array1, array2); System.out.println(Arrays.toString(mergedArray)); } java doc
Computers and Technology
1 answer:
uysha [10]3 years ago
7 0

Answer:

See explaination

Explanation:

import java.util.Arrays;

public class MergeArrays {

public static int[] merge(int[] array1, int[] array2) {

int[] result = new int[array1.length + array2.length];

int i = 0, j = 0, k = 0;

while (i < array1.length && j < array2.length) {

if (array1[i] < array2[j]) result[k++] = array1[i++];

else result[k++] = array2[j++];

}

while (i < array1.length) result[k++] = array1[i++];

while (j < array2.length) result[k++] = array2[j++];

return result;

}

public static void main(String[] args) {

int[] array1 = {1, 5, 16, 61, 111};

int[] array2 = {2, 4, 5, 6};

int[] mergedArray = merge(array1, array2);

System.out.println(Arrays.toString(mergedArray));

}

}

You might be interested in
What is an avenue in a Karel world?
Andrews [41]

Answer:

Karel's World  contains horizontal streets (running east-west) and vertical avenues (running north-south). can contain interior wall sections that are positioned between adjacent street corners and prevent Karel from moving directly between these street corners.

3 0
3 years ago
Read 2 more answers
What is a 96.1791 weighted gpa in a 4.0 scale?
Oksanka [162]

Answer:

3.85 out of 4

Explanation:

As 96.1791 out of 100 gives 96.1791% calculated below:

Percentage formula: (Obtained value/total value)*100.......eq(1)

Putting values:

= (96.1791/100)*100

= 96.1791%

Now finding 96.1791% of 4:

Putting values in eq (1):

96.1791% = (Obtained value/4)*100

96.1791/100= (Obtained value/4)    (dividing by 100 on both sides)

0.961791 = (Obtained value/4)

4* 0.961791 = Obtained value          (multiplying 4 on both sides)

3.847164 = Obtained value

Then 96.1791% of 4 will be equal to: 0.961791 * 4  = 3.847164

Rounding off the answer to 2 decimal places:

=3.85    (As the digit on 3rd decimal place is greater than 5)

4 0
3 years ago
How to make text icome one word at a timen filmora
bezimeni [28]

You would want to add multiple text slides.

I hope this helps as the wording of the question was unclear.

8 0
2 years ago
Who is the primary audience for demonstrations of game prototypes made by the developer?
padilas [110]

Answer:

the tester

Explanation:

When a video game is playable the first audience to test these prototypes are the tester, these people have to test all the game, and they have say all the information about errors, issues, bugs, and any difficulty to resolve these problems in a final video game's version, in this way the complete game arrives to the final audience.

5 0
3 years ago
What is the computer generation​
Inga [223]

Answer:

Generations of Computers Generation in computer terminology is a change in technology a computer is/was being used. Initially, the generation term was used to distinguish between varying hardware technologies. Nowadays, generation includes both hardware and software, which together make up an entire computer system.

3 0
3 years ago
Other questions:
  • Ron is creating building blocks in Word. How can he make the building blocks that he created available?
    11·2 answers
  • Write a MIPS assembly language program that prompts for a user to enter how many floating point numbers to enter, then prompts t
    10·1 answer
  • Write a program that will askthe user to enter the amount of a purchase. The program should thencompute the state and county sal
    5·1 answer
  • Does anybody know if that apple watch is actually worth what it costs?
    9·2 answers
  • Microsoft Windows is the least used operating system. TRUE or FALSE.
    13·1 answer
  • Why are computers complicated?
    15·1 answer
  • Question # 6
    11·2 answers
  • What kind is a utility file that shrinks the size of a file
    14·1 answer
  • You use lpstat and determine that a user named User1 has placed two large print jobs in the queue for Printer1 that have yet to
    9·1 answer
  • What kind of AR target category makes sense for a playing card with a picture on it?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!