Problem in MergeSort i need it in 1 Hour :-(

Hallo,
im trying to implement a Mergesort with test methode but the problem i can not start the code, i need help to solve this problem, that would be perfekt if i get that in 1 hour, i have to give the Answer to my Teacher!
hier ist my code:
public class MergeS
static void msort (int[] array, int le, int ri)
int i, j, k;
int [] b = new int [array.length];
if (ri > le) {
  // zu sortierendes Feld teilen
  int mitte = (ri + le) / 2;
  // teilfelder sortieren
  msort (array, le, mitte);
  msort (array, mitte + 1, ri);
  //Hilfsfeld aufbauen
  for (k = le; k <= mitte; k++)
    b[k] = array[k];
  for (k = mitte; k < ri; k++)
    b[ri + mitte - k] = array[k+1];
  // Ergebnisse mischen ?ber Hilfsfeld b
  i = le;
  j = ri;
  for (k = le; k <= ri; k++)
    if(b[i] < b[j])
      array[k] = b[i++];
    else
      array[k] = b[i--];
static void mergeSort (int[] array) {
  msort(array, 0, array.length - 1);
public static void main(String[] args)
int i;
int [] a;
int idx = AdvancedIO.readInt();
System.out.println("the Number of the Elements in the Array: " +idx);
a = new int[idx];
for (i = 0; i <= idx - 1; i++){
a = AdvancedIO.readInt();
System.out.println("Element with Index" + i + "Enter: " + a [i]);
SortierenA sArray = new SortierenA();
sArray.mergeSort(a);
System.out.print ("the Sorted Array is: " );
for (i=0; i <= idx -1; i++){
System.out.print (a[i]);
thank u very much!

the problem is solved, and about the merge part its was incorrect, thank u very much, owith out ur help, i could never find my mistake, hier ist the correct code:
public class MergeS
static void msort (int[] array, int le, int ri)
int i, j, k;
int [] b = new int [array.length];
if (ri > le) {
  // zu sortierendes Feld teilen
  int mitte = (ri + le) / 2;
  // teilfelder sortieren
  msort (array, le, mitte);
  msort (array, mitte + 1, ri);
  //Hilfsfeld aufbauen
  for (k = le; k <= mitte; k++)
    b[k] = array[k];
  for (k = mitte; k < ri; k++)
    b[ri + mitte - k] = array[k+1];
  // Ergebnisse mischen ?ber Hilfsfeld b
  i = le;
  j = ri;
  for (k = le; k <= ri; k++)
    if(b[i] < b[j])
      array[k] = b[i++];
    else
      array[k] = b[j--];
static void mergeSort (int[] array) {
  msort(array, 0, array.length - 1);
public static void main(String[] args)
int i;
int [] a;
System.out.println("the Number of the Elements in the Array: " );
int idx = AdvancedIO.readInt();
//System.out.println(idx);
a = new int[idx];
for (i = 0; i <= idx - 1; i++){
   System.out.println("the Element with Index - " + i + " should be ");
    a = AdvancedIO.readInt();
//System.out.println(a[i]);
MergeS sArray = new MergeS();
sArray.mergeSort(a);
System.out.print ("the Sorted Array is: " );
for (i=0; i <= idx -1; i++){
System.out.print (a[i]);

Similar Messages

Maybe you are looking for

  • Very odd and very large file found in system library: maremoted

    Hello, Using a single 1.25 G4 with 10.3.9. It's been acting up and running out of space. We located a file called maremoted, (which we're guessing is some kind of Remote Daemon), fil, which is upwards of 30 GB. It's run by the root user and trying to

  • HELP....AVCHD / MPEG files not playing correctly!

    I have been trying to download video that was shot with the new Sony FS100 camera that I'm told are AVCHD or MPEG files to my older Adobe Premiere Pro 1.5 timeline, but they are not playing correctly. When I reverse the field dominance, the image pla

  • Order By clause problem with ENAME and Rownum?

    From Scott/Tiger user I run this query from EMP table. select rownum,EMPNO,ENAME,JOB from emp order by Ename; Output is like this ROWNUM EMPNO ENAME JOB 11      11     ADAMS CLERK 2      2      ALLEN SALESMAN 6      6      BLAKE MANAGER 7      7     

  • Problem with rotate (Win 10)

    For some reason, my Yoga 2 Pro refuses to get back into the 'normal' rotation (NOT upside-down or sideways). I've tried disabling ymg in services (no effect), I've tried with the ctrl-alt combo (all of them work perfectly, EXCEPT for the ctrl-alt-UP

  • Using native Logic OSC support with 3rd party plug-ins & new touchOSC maps

    Hi All. Now that logic from 9.1.2 has native OSC support, I wandered if anyone has used it succesfully with their own customised touchOSC maps? I'm not so interested in using touchsc as a transport/mixer for logic - which is what the default logic ma