Skip to main content
added 7 characters in body
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237

didDid you try to execute the algorithm with an array that has only 1 element. E (e.g. A=[1]. If A=[1])? If you search for the value 1, it'll give "false"false, or in this case "-1"-1, because low == highlow == high and the loop body is never entered despite the value 1 being part of the array. It might be faster, but will fail to deliver the right answer for at least one casescase.

did you try to execute the algorithm with an array that has only 1 element. E.g. A=[1]. If you search for the value 1 it'll give "false" or in this case "-1" because low == high and the loop body is never entered despite the value 1 being part of the array. It might be faster but will fail to deliver the right answer for at least one cases.

Did you try to execute the algorithm with an array that has only 1 element (e.g. A=[1])? If you search for the value 1, it'll give false, or in this case -1, because low == high and the loop body is never entered despite the value 1 being part of the array. It might be faster, but will fail to deliver the right answer for at least one case.

Source Link

did you try to execute the algorithm with an array that has only 1 element. E.g. A=[1]. If you search for the value 1 it'll give "false" or in this case "-1" because low == high and the loop body is never entered despite the value 1 being part of the array. It might be faster but will fail to deliver the right answer for at least one cases.