Question
1. Implement the following method in a class named ArrayUtils.java public static int[] merge(int[] arr1, int[] arr2) The method merges two sorted arrays into one
1. Implement the following method in a class named ArrayUtils.java
public static int[] merge(int[] arr1, int[] arr2)
The method merges two sorted arrays into one and returns the new array. For example, if
arr1 = {4, 8, 10}; and arr2 = {3, 7, 9};, then the returned array should be {3, 4, 7, 8, 9, 10}.
You should not merge the array and then sort the new array. Think about the strategy to merge the arrays and write the pseudocode as comments in your implementation.
2. Implement the following method in Partition class.
public static int partition(int[] elements) {
}
The partition function will partition the array elements using the elements[0] into two parts. After the partition, the value of elements[0] should stay at position index, such that all the elements to the left of the index are smaller or equals to elements[0], and all the elements to the right are larger.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started