File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed
Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change 77*/
88Array . prototype . heapify = function ( index , heapSize ) {
99
10- var largest = index ;
11- var leftIndex = 2 * index + 1 ;
12- var rightIndex = 2 * index + 2 ;
10+ let largest = index ;
11+ let leftIndex = 2 * index + 1 ;
12+ let rightIndex = 2 * index + 2 ;
1313
1414 if ( leftIndex < heapSize && this [ leftIndex ] > this [ largest ] ) {
1515 largest = leftIndex ;
@@ -20,7 +20,7 @@ Array.prototype.heapify = function (index, heapSize) {
2020 }
2121
2222 if ( largest !== index ) {
23- var temp = this [ largest ] ;
23+ let temp = this [ largest ] ;
2424 this [ largest ] = this [ index ] ;
2525 this [ index ] = temp ;
2626
@@ -35,13 +35,13 @@ Array.prototype.heapify = function (index, heapSize) {
3535*/
3636function heapSort ( items ) {
3737
38- var length = items . length ;
38+ let length = items . length ;
3939
40- for ( var i = Math . floor ( items . length / 2 ) - 1 ; i > - 1 ; i -- ) {
40+ for ( let i = Math . floor ( length / 2 ) - 1 ; i > - 1 ; i -- ) {
4141 items . heapify ( i , length ) ;
4242 }
43- for ( var j = length - 1 ; j > 0 ; j -- ) {
44- var tmp = items [ 0 ] ;
43+ for ( let j = length - 1 ; j > 0 ; j -- ) {
44+ let tmp = items [ 0 ] ;
4545 items [ 0 ] = items [ j ] ;
4646 items [ j ] = tmp ;
4747 items . heapify ( 0 , j ) ;
You can’t perform that action at this time.
0 commit comments