Question: JAVA Scenario Merge sorting is one of the fastest sorting techniques. It is used in many bundled libraries and APIs. In this activity, we will

JAVA

Scenario

Merge sorting is one of the fastest sorting techniques. It is used in many bundled libraries and APIs. In this activity, we will write an algorithm in Java to sort an array using merge sort.

Aim

Use the pseudocode shown in Snippet 2.11 and Snippet 2.12 to implement the full merge sort algorithm in Java.

Your MergeSort class should contain 3 methods, other than the main() stub.

JAVA Scenario Merge sorting is one of the fastest sorting techniques. Itis used in many bundled libraries and APIs. In this activity, we

Steps for Completion

  1. Start from the mergeSort() method, which splits the array in two, recursively sorts both, and merges the result.
  2. Then, implement the merge method, which merges both ends of the split array into another space.
  3. After the merge is done, copy the new array back in place of the input array.

REQUIRED TASKS

The mergeSort() method handles a sorted array as a parameter and an array with identical elements.

The mergeSort() method handles sorting even and odd elements

The mergeSort() method handles sorting an empty array and an array with one element.

GIVEN CODE:

public class MergeSort {

// Write your code here

public static void main(String[] args) { /* * This main method is a stub. * It does nothing. * Feel free to write your own code to test your implementation. * In this case, we have nothing actionable in here, just this comment block, so the JVM should rapidly lose interest and move on to the rest of your code. */ }

}

mergeSort(array, start, end) if(start end || array[i]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!