Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b404da0

Browse filesBrowse files
committed
add all
1 parent 1e11863 commit b404da0
Copy full SHA for b404da0

File tree

5 files changed

+83
-39
lines changed
Filter options

5 files changed

+83
-39
lines changed

‎.idea/workspace.xml

Copy file name to clipboardExpand all lines: .idea/workspace.xml
+80-25Lines changed: 80 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
-16 Bytes
Binary file not shown.
Binary file not shown.

‎src/com/company/Lecture11/MergeSort.java

Copy file name to clipboardExpand all lines: src/com/company/Lecture11/MergeSort.java
+1-6Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,10 @@ public static void main(String[] args) {
77
int[] nums = {3,8,1,9,2};
88
nums = mergeSort(nums);
99
System.out.println(Arrays.toString(nums));
10-
1110
}
1211

1312
public static int[] mergeSort(int[] nums){
14-
if(nums.length < 2){
15-
return nums;
16-
}
17-
13+
if(nums.length < 2) return nums;
1814
int mid = nums.length/2;
1915

2016
int[] first = Arrays.copyOfRange(nums,0,mid);
@@ -30,7 +26,6 @@ public static int[] merge(int[] first, int[] second){
3026
int i=0,j=0,k=0;
3127
int[] res = new int[first.length+second.length];
3228

33-
3429
while(i < first.length && j < second.length){
3530
if(first[i] < second[j]){
3631
res[k++] = first[i++];

‎src/com/company/Lecture11/QuickSort.java

Copy file name to clipboardExpand all lines: src/com/company/Lecture11/QuickSort.java
+2-8Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,14 @@ public static void quicksort(int[] nums,int start, int end){
2424
}
2525

2626
public static int pivot(int[] nums,int start,int end){
27-
// int p = start;
28-
//
29-
// ArrayIntro.swap(nums,p,end);
30-
31-
int p = end;
3227
int j=start;
33-
3428
for (int i = start; i <= end; i++) {
35-
if(nums[i] < nums[p]) {
29+
if(nums[i] < nums[end]) {
3630
ArrayIntro.swap(nums, i, j);
3731
j++;
3832
}
3933
}
40-
ArrayIntro.swap(nums,p,j);
34+
ArrayIntro.swap(nums, end,j);
4135
return j;
4236
}
4337
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.