Skip to content

Commit e7b7709

Browse files
committed
added chapter 10
1 parent 4603442 commit e7b7709

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

chapter10/01-SortingAlgorithms.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ function ArrayList(){
121121
return result;
122122
};
123123

124-
this.quickStort = function(){
124+
this.quickSort = function(){
125125
quick(array, 0, array.length - 1);
126126
};
127127

@@ -141,7 +141,7 @@ function ArrayList(){
141141
}
142142

143143
if (i <= j) {
144-
swap(array, i, j);
144+
swapQuickStort(array, i, j);
145145
i++;
146146
j--;
147147
}
@@ -150,6 +150,12 @@ function ArrayList(){
150150
return i;
151151
};
152152

153+
var swapQuickStort = function(array, index1, index2){
154+
var aux = array[index1];
155+
array[index1] = array[index2];
156+
array[index2] = aux;
157+
};
158+
153159
var quick = function(array, left, right){
154160

155161
var index;

chapter10/02-UsingSortingAlgorithms.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ array = createNonSortedArray();
6464

6565
console.log(array.toString());
6666

67-
array.mergeSort();
67+
array.quickSort();
6868

6969
console.log(array.toString());
7070

0 commit comments

Comments
 (0)