Skip to content

Commit

Permalink
Fixed quicksort
Browse files Browse the repository at this point in the history
  • Loading branch information
nzakas committed Dec 1, 2012
1 parent 3d611c1 commit c84c42c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions algorithms/sorting/quicksort/quicksort.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function swap(items, firstIndex, secondIndex){

function partition(items, left, right) {

var pivot = items[Math.ceil((right + left) / 2)], // pivot value is middle item
var pivot = items[Math.floor((right + left) / 2)], // pivot value is middle item
i = left, // starts from left and goes right to pivot index
j = right; // starts from right and goes left to pivot index

Expand Down Expand Up @@ -94,7 +94,7 @@ function quickSort(items, left, right) {
}

if (index < right) {
quickSort(items, index + 1, right);
quickSort(items, index, right);
}

}
Expand Down

0 comments on commit c84c42c

Please sign in to comment.