Skip to content

Commit

Permalink
Update QuickSort.java
Browse files Browse the repository at this point in the history
  • Loading branch information
jsjtzyy authored Feb 14, 2021
1 parent 95ae62d commit b07b389
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions QuickSort/QuickSort.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ public void quickSort(int[] nums, int start, int end){
quickSort(nums, pos + 1, end);
}

/**
* maintain two pointers:
* pos points to cur element that <= pivot
*. i is ahead of pos and tries to find next element <= pivot and swap to nums[pos + 1]
*/
public int partition(int[] nums, int start, int end){
int pivot = nums[end];
int pos = start - 1, tmp = 0;
Expand Down

0 comments on commit b07b389

Please sign in to comment.