This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://en.wikipedia.org/wiki/Quicksort#Hoare_partition_scheme | |
function quickSort(arr, lo, hi) { | |
if (lo >= 0 && hi >= 0 && lo < hi) { | |
const p = partition(arr, lo, hi); | |
quickSort(arr, lo, p); | |
quickSort(arr, p + 1, hi); | |
} | |
} | |
function partition(arr, lo, hi) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://en.wikipedia.org/wiki/Quicksort#Lomuto_partition_scheme | |
function quickSort(arr, lo, hi) { | |
if (lo >= hi || lo < 0) return; | |
const p = partition(arr, lo, hi); | |
quickSort(arr, lo, p - 1); | |
quickSort(arr, p + 1, hi); | |
} | |
function partition(arr, lo, hi) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function quickSort(arr) { | |
if (arr.length <= 1) { | |
return arr; | |
} | |
const less = []; | |
const greater = []; | |
const pivot = arr[arr.length - 1]; | |
for (let i = 0; i < arr.length - 1; ++i) { | |
const num = arr[i]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- index.html --> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>React Tutorial</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react-dom.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script> |