Skip to content

Instantly share code, notes, and snippets.

@PantherHawk
Created February 23, 2017 17:34
Show Gist options
  • Save PantherHawk/d9b1699582a6511babaa8f3ba9bd8311 to your computer and use it in GitHub Desktop.
Save PantherHawk/d9b1699582a6511babaa8f3ba9bd8311 to your computer and use it in GitHub Desktop.
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