Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement