R
R
rsatarov2016-10-09 15:57:38
Java
rsatarov, 2016-10-09 15:57:38

Can you help find an error in the algorithm (binary search)?

The problem is in the method of adding an element to an array.
pastebin.com/9d7NXKVf
Input numbers: 3, 7, 2, 8, 0, 10, 3, 63, 43, 37, 86, 23
It turns out like this: 0, 2, 3, 3, 7, 8, 43, 37, 10, 23, 63, 86

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2016-10-09
@rsatarov

Replace upperBound = currentIndex - 1;with upperBound = currentIndex;.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question