Skip to content

Instantly share code, notes, and snippets.

@andrewsouthard1
Created May 10, 2017 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewsouthard1/3790bc7ed64a492f3e6bc2bcb519f77d to your computer and use it in GitHub Desktop.
Save andrewsouthard1/3790bc7ed64a492f3e6bc2bcb519f77d to your computer and use it in GitHub Desktop.
Binary Search - First Draft
def binary_search(n, arr)
middle = arr[arr.length / 2]
if middle == n
return true
elsif middle < n
i = middle
j = arr.length - 1
middle = i + j / 2
else
i = 0
j = middle
middle = i + j / 2
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment