Skip to content

Commit 3bdceca

Browse files
authored
Merge pull request larissalages#22 from ani538/master
Removed bugs from MergeSort.java
2 parents 93e51cd + 452c629 commit 3bdceca

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

classical_algorithms/MergeSort.class

2.21 KB
Binary file not shown.

classical_algorithms/MergeSort.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import java.util.*;
2-
import java.lang.*;
32

43

54
class MergeSort
@@ -73,21 +72,19 @@ static void printArray(int a[], int n)
7372

7473
public static void main(String args[])
7574
{
75+
Scanner scan= new Scanner(System.in);
7676
try{
77-
int low,high,mid;
77+
int low,high;
7878
int n,i;
79-
80-
Scanner scan= new Scanner(System.in);
81-
8279
System.out.println("How many elements do you want in the array?");
8380
n=scan.nextInt();
8481
int a[]= new int[n];
8582
System.out.println("Enter the array elements one by one");
83+
8684
for(i=0;i<n;i++)
87-
{
88-
a[i]=scan.nextInt();
85+
{
86+
a[i]=scan.nextInt();
8987
}
90-
9188
System.out.println("Array before sorting is:");
9289
printArray(a, n);
9390
low=0;
@@ -101,7 +98,7 @@ public static void main(String args[])
10198
printArray(a, n);
10299

103100
}catch(Exception e){e.printStackTrace();}
104-
101+
scan.close();
105102
}
106103
}
107104

0 commit comments

Comments
 (0)