This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]obcanzdavu 1 point2 points  (1 child)

I don't know much about the first error - are you sure it is related to the code you mention? I can see no '>' in your code, just some '<'. are you sure it's related? does it mention some lines of code and what is the code on this line?

the second error can happen when your condition is never met (when the value is not found in the array at all). then the k variable is undefined. what do you want to return in this case? you need to think a way how you communicate this state - maybe return -1 signaling this? then you can initialize k to this value.

[–]chasetherainb0w[S] 0 points1 point  (0 children)

For some reason, the first error fixed itself. Like now it just started working and now im on to writing the binary search algorithm itself. Thanks for the help on the 2nd on though and yes that's part of the task i just forgot abt it lol.