Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. let binaryBubbleSort = (array) => {
  2. var lowIndex = array[0];
  3. var highIndex = array[array.length -1];
  4. var timesThrough = 0;
  5. while (lowIndex <= highIndex){
  6. var middleIndex = (highIndex + lowIndex) / 2;
  7.  
  8. if (array[middleIndex] < value) {
  9. lowIndex = middleIndex + 1;
  10. } else if (array[middleIndex] > value) {
  11. highIndex = middleIndex + 1;
  12. } else {
  13. console.log(`index matches ${middleIndex}`)
  14. lowIndex = highIndex + 1;
  15. }
  16. timesThrough++;
  17. }
  18. }
  19.  
  20. //O(n log n)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement