Question: Modify the Javaalgorithm so that it splits the list into 3 sublists (instead of two). Each sublist should contain about n/3 items. The algorithm should

Modify the Javaalgorithm so that it splits the list into 3 sublists (instead of two). Each sublist should contain about n/3 items. The algorithm should sort each sublist recursively and merge the three sorted sublists. The traditional merge sort algorithm has an average and worst-case performance of O(n log2 n). What is the performance of the newly made algorithm?

import java.util.Arrays; public class MergeSort { public static void main(String[] args) { int[] values = new int[15]; for(int i=0; imin) { int pivot = (min+max)/2; sort(data, min, pivot); sort(data, pivot+1, max); int left = min; //the beginning of the left sublist int right = pivot+1; //the beginning of the right sublist int[] merged = new int[max-min+1]; for(int i=0; imax || data[left]

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!