Update BinarySearch.go (#73)

fix bug(panic for empty array)
This commit is contained in:
Xinhai Wang
2018-07-19 07:00:44 +08:00
committed by Aditya Bhargava
parent d13ab114f8
commit 522efcbc31

View File

@@ -2,18 +2,10 @@ package main
import "fmt"
func getBool(i, j int) bool {
if i <= j{
return true
}else {
return false
}
}
func checkBin(list []int, i int) bool {
low := 0
high := len(list) -1
for ok := true;ok ;ok = getBool(low,high) {
for low <= high {
mid:= (low+high)/2
if list[mid] == i{
return true