Computers and Technology

You’ve done merge (on Lists), so now it’s time to do merge sort (on arrays). Create a public non-final class named MergeSort that extends Merge. Implement a public static method int[] mergesort(int[] values) that returns the input array of ints sorted in ascending order. You will want this method to be recursive, with the base case being an array with zero or one value. If the passed array is null you should return null. If the passed array is empty you should return an empty array. You do not have to sort the array in place, but the returned array does not have to be a copy. To help you your parent class Merge provides two useful class methods: int[] merge(int[] first, int[] second): this merges two sorted arrays into a second sorted array. If either array is null it returns null, so you should not call it on a null array. int[] copyOfRange(int[] original, int from, int to): this acts as a wrapper on Arrays. copyOfRange, accepting the same arguments and using them in the same way. (You can’t use java. util. Arrays in this problem for reasons that will become obvious if you inspect the rest of the documentation…) Note that the test code will test that you call merge an appropriate number of times, so you should call it to join single-element arrays together.

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 00:30, Thisisdifinite
Which of the following would you find on a network
Answers: 3
image
Computers and Technology, 23.06.2019 09:30, ranmmm
The place where the extended axis of the earth would touch the celestial sphere is called the celestial
Answers: 1
image
Computers and Technology, 23.06.2019 19:00, brittneyrenae7338
This question involves a class named textfile that represents a text file. public class textfile { private string filename; private string filename; private arraylist words; // constructors not shown // postcondition: returns the number of bytes in this file public int filesize() { } // precondition: 0 < = index < words. size() // postcondition: removes numwords words from the words arraylist beginning at // index. public void deletewords(int index, int numwords) { } // precondition: 0 < = index < = words. size() // postcondition: adds elements from newwords array to words arraylist beginning // at index. pub lic voidaddwords(int index, string[] newwords) { } // other methods not shown } complete the filesize() method. the filesize() is computed in bytes. in a text file, each character in each word counts as one byte. in addition, there is a space in between each word in the words arraylist, and each of those spaces also counts as one byte. for example, suppose the words arraylist stores the following words: { mary had a little lamb; its fleece was white as snow. } the filesize() method would compute 4 + 3 + 1 + 6 + 5 + 4 + 6 + 3 + 5 + 2 + 5 as the sum of the lengths of each string in the arraylist. the value returned would be this sum plus 10, because there would also be 10 spaces in between the 11 words. complete the filesize() method below: // postcondition: returns the number of bytes in this file public int filesize() { }
Answers: 1
image
Computers and Technology, 24.06.2019 08:20, bob4059
Evaluate the scenario below and indicate how to handle the matter appropriately. situation: michael received an e-mail from what he thought was his doctor’s office, requesting his social security number. since he had just been in to see his doctor last week, he replied to the e-mail with his social security number.
Answers: 2
Do you know the correct answer?
You’ve done merge (on Lists), so now it’s time to do merge sort (on arrays). Create a public non-fin...

Questions in other subjects:

Konu
Mathematics, 21.08.2020 19:01
Konu
Mathematics, 21.08.2020 19:01
Konu
Mathematics, 21.08.2020 19:01