Update Binary_Search.mdx

This commit is contained in:
Darren Yao 2020-06-29 13:35:37 -07:00 committed by GitHub
parent 4a81683f4a
commit 75d46a0fd0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -111,6 +111,8 @@ static boolean check(long x){
}
```
Note that I used the `Arrays.sort()` function, which uses quicksort on primitive data types such as `long`s. This is fine for USACO, but in other contests, such as CodeForces, it may time out on test cases specifically engineered to trigger worst-case O(n^2) behavior in quicksort. In such contests, you should declare the underlying array as an array of objects, for example `Long` instead of `long`. This forces the `Arrays.sort()` function to use mergesort, which is always O(n log n).
C++:
```cpp