Skip to content

Commit

Permalink
operation optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
LYDongD committed Nov 14, 2018
1 parent 0a2b60c commit 66e8cfc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions go/binarysearch2.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ func BinarySearch2(nums []int, value int) int {
start := 0
end := length - 1
for start <= end {
mid := start + ((end - start) >> 2)
mid := start + ((end - start) >> 1)
if nums[mid] > value {
end = mid - 1
} else if nums[mid] < value {
Expand All @@ -29,7 +29,7 @@ func BinarySearch3(nums []int, value int) int {
start := 0
end := len(nums) - 1
for start <= end {
mid := (start + end) / 2
mid := start + ((end - start) >> 1)
if nums[mid] > value {
end = mid - 1
} else if nums[mid] < value {
Expand Down

0 comments on commit 66e8cfc

Please sign in to comment.