Skip to content

Commit 2743b7c

Browse files
committed
Add use strict to heap sort
1 parent 823e332 commit 2743b7c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/sorting/heapsort/heapsort.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
(function (exports) {
22

3+
'use strict';
4+
35
function comparator(a, b) {
46
return a - b;
57
}
@@ -16,18 +18,21 @@
1618
*
1719
* @private
1820
* @param {array} array Array
19-
* @param {number} index Index of the element which palce in the max heap should be found.
21+
* @param {number} index Index of the element which palce in
22+
* the max heap should be found.
2023
*/
2124
function heapify(array, index, heapSize, cmp) {
2225
var left = 2 * index + 1,
2326
right = 2 * index + 2,
2427
largest = index;
2528

26-
if (left < heapSize && cmp(array[left], array[index]) > 0)
29+
if (left < heapSize && cmp(array[left], array[index]) > 0) {
2730
largest = left;
31+
}
2832

29-
if (right < heapSize && cmp(array[right], array[largest]) > 0)
33+
if (right < heapSize && cmp(array[right], array[largest]) > 0) {
3034
largest = right;
35+
}
3136

3237
if (largest !== index) {
3338
var temp = array[index];

0 commit comments

Comments
 (0)