1
1
/*
2
- * Build a max heap out of the array. A heap is a specialized tree like
3
- * data structure that satisfies the heap property. The heap property
4
- * for max heap is the following: "if P is a parent node of C, then the
5
- * key (the value) of node P is greater than the key of node C"
6
- * Source: https://en.wikipedia.org/wiki/Heap_(data_structure)
7
- */
8
-
2
+ * Build a max heap out of the array. A heap is a specialized tree like
3
+ * data structure that satisfies the heap property. The heap property
4
+ * for max heap is the following: "if P is a parent node of C, then the
5
+ * key (the value) of node P is greater than the key of node C"
6
+ * Source: https://en.wikipedia.org/wiki/Heap_(data_structure)
7
+ */
8
+ /* eslint no-extend-native: ["off", { "exceptions": ["Object"] }] */
9
9
Array . prototype . heapify = function ( index , heapSize ) {
10
10
let largest = index
11
11
const leftIndex = 2 * index + 1
@@ -29,10 +29,10 @@ Array.prototype.heapify = function (index, heapSize) {
29
29
}
30
30
31
31
/*
32
- * Heap sort sorts an array by building a heap from the array and
33
- * utilizing the heap property.
34
- * For more information see: https://en.wikipedia.org/wiki/Heapsort
35
- */
32
+ * Heap sort sorts an array by building a heap from the array and
33
+ * utilizing the heap property.
34
+ * For more information see: https://en.wikipedia.org/wiki/Heapsort
35
+ */
36
36
function heapSort ( items ) {
37
37
const length = items . length
38
38
0 commit comments