Skip to content
Merged

sort/ #150

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Sorts/bogoSort.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 11 additions & 11 deletions Sorts/heapSort.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* Build a max heap out of the array. A heap is a specialized tree like
* data structure that satisfies the heap property. The heap property
* for max heap is the following: "if P is a parent node of C, then the
* key (the value) of node P is greater than the key of node C"
* Source: https://en.wikipedia.org/wiki/Heap_(data_structure)
*/

* Build a max heap out of the array. A heap is a specialized tree like
* data structure that satisfies the heap property. The heap property
* for max heap is the following: "if P is a parent node of C, then the
* 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
Expand All @@ -29,10 +29,10 @@ Array.prototype.heapify = function (index, heapSize) {
}

/*
* Heap sort sorts an array by building a heap from the array and
* utilizing the heap property.
* For more information see: https://en.wikipedia.org/wiki/Heapsort
*/
* Heap sort sorts an array by building a heap from the array and
* utilizing the heap property.
* For more information see: https://en.wikipedia.org/wiki/Heapsort
*/
function heapSort (items) {
const length = items.length

Expand Down
1 change: 1 addition & 0 deletions Sorts/wiggleSort.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down