Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8ac2c1a

Browse files
add go mod & change errata binary search
1 parent f843a3d commit 8ac2c1a

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

‎binarySearch/binarySearch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func binSearch(list []int, item int) {
2323
high := len(list) - 1
2424

2525
for low <= high {
26-
mid := (low + high)
26+
mid := (low + high)/2
2727
guess := list[mid]
2828
if guess == item {
2929
fmt.Printf("Position:\t%v\n", mid)

‎go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module algorithm
2+
3+
go 1.17
4+
5+
require github.com/dreddsa5dies/algorithm v0.0.0-20210807072651-68e310fc4e7c

‎go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github.com/dreddsa5dies/algorithm v0.0.0-20210807072651-68e310fc4e7c h1:+IsVypOBnNZpGvjI4ryPEU0ybiMiAxtDLJLnIBjCB+c=
2+
github.com/dreddsa5dies/algorithm v0.0.0-20210807072651-68e310fc4e7c/go.mod h1:GGavcA9TE70M+HEmeEx2UTTitaMvUbwQ4r1apSyHln0=

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /