Created
February 23, 2017 17:34
-
-
Save PantherHawk/d9b1699582a6511babaa8f3ba9bd8311 to your computer and use it in GitHub Desktop.
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
let binaryBubbleSort = (array) => { | |
var lowIndex = array[0]; | |
var highIndex = array[array.length -1]; | |
var timesThrough = 0; | |
while (lowIndex <= highIndex){ | |
var middleIndex = (highIndex + lowIndex) / 2; | |
if (array[middleIndex] < value) { | |
lowIndex = middleIndex + 1; | |
} else if (array[middleIndex] > value) { | |
highIndex = middleIndex + 1; | |
} else { | |
console.log(`index matches ${middleIndex}`) | |
lowIndex = highIndex + 1; | |
} | |
timesThrough++; | |
} | |
} | |
//O(n log n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment