Question: Make sure that I can be able to merge two sorted arrays into one. For some reason my Eclipse is not running my Java programs.
Make sure that I can be able to merge two sorted arrays into one. For some reason my Eclipse is not running my Java programs. So I need help to make sure everything runs smoothly
package Test2;
public class Test2 {
public static void main(String[] args) {
int[] list = {7,8,7,10,11,6,3,8,19,17};
mergeSort(list);
for (int i = 0; i < list.length; i++)
System.out.print(list[i] + " ");
}
public static void mergeSort(int [] list) {
if (list.length > 1) {
int[] firstHalf = new int[list.length / 2];
System.arraycopy(list, 0, firstHalf, 0, list.length / 2);
mergeSort(firstHalf);
int secondHalfLength = list.length - list.length / 2;
int[] secondHalf = new int[secondHalfLength];
System.arraycopy(list, list.length / 2, secondHalf, 0, secondHalfLength);
mergeSort(secondHalf);
merge(firstHalf, secondHalf, list);
}
}
public static void merge(int[] list1, int[] list2, int[] temp) {
int current1 = 0;
int current2 = 0;
int current3 = 0;
while (current1 < list1.length && current2 < list2.length) {
if (list1[current1] < list2[current2])
temp[current3++] = list1[current1++];
else
temp[current3++] = list2[current2++];
}
while (current1 < list1.length)
temp[current3++] = list1[current1++];
while (current2 < list2.length)
temp[current3++] = list2[current2++];
}
}
eclipse-workspace - Test2/src/Test2/Test2.java - Eclipse IDE File Edit Source Refactor Navigate Package Explorer X Grossincomes Homework1 Homework2 > JRE System Library [JavaSE-17] src homework2 > Homework2.java HW1 Loop LoopExercise > JRE System Library [JavaSE-17] src loopexercise LoopExercise.java > module-info.java marathonrace MyBasicArrayList > JRE System Library [JavaSE-17] src mybasicarraylist MyBasicArrayList.java MyFactiorial2 MyFactorial Myinput MyMenu MyMenu1 New Search > JRE System Library [JavaSE-17] src lincoln > Lincoln.java module-info.java SquareOverloading Student Test2 > JRE System Library [JavaSE-17] src Test2 > Test2.java Tact2 Project Run T Window Help *Homework2.java 1 package Test2; Test2.java X *Test3.java ArrayListPrint.java ArrayCopy.java MyBasicArrayList.java 2 3 public class Test2 { 4 50 69 7 public static void main(String[] args) { int[] list = {7,8,7,10,11,6,3,8,19,17}; mergeSort (list);B for (int i = 0; i < list.length; i++) System.out.print(list[i] + "); public static void mergeSort (int [ ] list) { 8 9 10 } 11 13 1234567 120 if (list.length > 1) { int[] firstHalf = new int[list.length / 2]; System.arraycopy(list, 0, firstHalf, , list.length / 2); mergeSort(firstHalf); int secondHalfLength = list.length - list.length / 2; int[] second Half = new int[secondHalfLength]; System.arraycopy(list, list.length / 2, secondHalf, 0, secondHalfLength); mergeSort(secondHalf); 17 18 19 20 21 22 23 24 } 25 } merge(firstHalf, secondHalf, list); 27 260 public static void merge(int[] list1, int[] list2, int[] temp) { int current1 = 0; 28 int current2 = 0; 29 int current3 = 0; 30 31 32 while (current1 < list1.length && current2 < list2.length) { if (list1[current1] < list2[current2]) temp[current3++] = list1[current1++]; 33 else 34 temp[current3++] = list2[current2++]; 35 } 36 37 38 39 while (current1 < list1.length) temp[current3++] list1[current1++]; while (current2 < list2.length) temp[current3++] = list2[current2++]; 40 41 } 42} 43 | = Problems @Javadoc Declaration Console X Coverage New_configuration [Java Application] C:\Users\jonat\.p2\pool\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.3.v20220515-1416\jre\bin\javaw.exe (Jul 10, 2022, 5:21:38 PM 5:21:38 PM Error: Could not find or load main class
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
