Binary Search
More to come! var doSearch = function(array, targetValue) { var min = 0; var max = array.length – 1; var guess; var i = 0; while(min <= max) { i = i++; guess = Math.floor((max + min) / 2); if (array[guess] === targetValue) { println(guess); println("Number of guesses " + i); return guess; } else […]
Read more "Binary Search"