File tree 3 files changed +11
-6
lines changed
linkedList/collectionFramework
3 files changed +11
-6
lines changed Original file line number Diff line number Diff line change 1
1
package array .sorting ;
2
2
3
+ import java .util .ArrayList ;
3
4
import java .util .Arrays ;
4
5
5
6
public class MergeSort {
@@ -16,18 +17,18 @@ static int[] mergeSort(int[] array){
16
17
return merge (left , right );
17
18
}
18
19
19
- static int [] merge (int [] first , int [] second ) {
20
+ static int [] merge (int [] first , int [] second ) {
20
21
int [] mix = new int [first .length + second .length ];
21
22
22
23
int i = 0 ;
23
24
int j = 0 ;
24
25
int k = 0 ;
25
26
26
27
while (i < first .length && j < second .length ) {
27
- if (first [i ] < second [j ]){
28
+ if (first [i ] < second [j ]) {
28
29
mix [k ] = first [i ];
29
30
i ++;
30
- }else {
31
+ } else {
31
32
mix [k ] = second [j ];
32
33
}
33
34
k ++;
@@ -49,4 +50,5 @@ static int[] merge(int[] first, int[] second) {
49
50
50
51
return mix ;
51
52
}
53
+
52
54
}
Original file line number Diff line number Diff line change @@ -17,17 +17,20 @@ public static void main(String[] args) {
17
17
// display using iterator
18
18
Iterator <String > itr = list .iterator ();
19
19
20
+ System .out .println ("Display using iterator : " );
20
21
while (itr .hasNext ()) {
21
22
String item = itr .next ();
22
- System .out .println (item + " " );
23
+ System .out .print (item + " " );
23
24
}
24
25
26
+ System .out .println ();
25
27
// modify using iterator
26
28
ListIterator <String > lsItr = list .listIterator ();
27
29
30
+ System .out .println ("Modify using iterator : " );
28
31
while (lsItr .hasNext ()) {
29
32
String item = lsItr .next ();
30
- System .out .println (item + " " );
33
+ System .out .print (item + " " );
31
34
}
32
35
33
36
}
Original file line number Diff line number Diff line change 1
- package collectionFramework ;
1
+ package linkedList . collectionFramework ;
2
2
3
3
import java .util .LinkedList ;
4
4
You can’t perform that action at this time.
0 commit comments