You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After trying a test case where I search for an element that is not in the data slice I get an error panic: runtime error: index out of range. I'm not sure why a +1 was added but when I remove it the problem goes away.
Searching for 0
Position: 0 data: 0
Searching for 4
Position: 4 data: 4
Searching for 9
Position: 9 data: 9
Searching for 11
Key 11 not found
Searching for 2
Position: 2 data: 2
Searching for 3
Position: 3 data: 3
Searching for 8
Position: 8 data: 8
Searching for -1
Key -1 not found
Position: -1
The text was updated successfully, but these errors were encountered:
Why do you add 1 to the
boundValue
here https://github.com/floyernick/Data-Structures-and-Algorithms/blob/master/ExponentialSearch/ExponentialSearch.go#L11 in the exponential search algorithm?After trying a test case where I search for an element that is not in the data slice I get an error
panic: runtime error: index out of range
. I'm not sure why a+1
was added but when I remove it the problem goes away.All of my code:
Output:
The text was updated successfully, but these errors were encountered: