mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 16:26:47 +08:00
sort/
This commit is contained in:
@ -2,6 +2,8 @@
|
||||
* A simple helper function that checks, if the array is
|
||||
* sorted in ascending order.
|
||||
*/
|
||||
|
||||
/* eslint no-extend-native: ["off", { "exceptions": ["Object"] }] */
|
||||
Array.prototype.isSorted = function () {
|
||||
const length = this.length
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
* key (the value) of node P is greater than the key of node C"
|
||||
* Source: https://en.wikipedia.org/wiki/Heap_(data_structure)
|
||||
*/
|
||||
|
||||
/* eslint no-extend-native: ["off", { "exceptions": ["Object"] }] */
|
||||
Array.prototype.heapify = function (index, heapSize) {
|
||||
let largest = index
|
||||
const leftIndex = 2 * index + 1
|
||||
|
@ -4,6 +4,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* eslint no-extend-native: ["off", { "exceptions": ["Object"] }] */
|
||||
Array.prototype.wiggleSort = function () {
|
||||
for (let i = 0; i < this.length; ++i) {
|
||||
const shouldNotBeLessThan = i % 2
|
||||
|
Reference in New Issue
Block a user