From 75d46a0fd02f51181a3a7eb8b5d8e2fa72b7f7c3 Mon Sep 17 00:00:00 2001 From: Darren Yao Date: Mon, 29 Jun 2020 13:35:37 -0700 Subject: [PATCH] Update Binary_Search.mdx --- content/4_Silver/Binary_Search.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/content/4_Silver/Binary_Search.mdx b/content/4_Silver/Binary_Search.mdx index 5df55cc..17bbdf0 100644 --- a/content/4_Silver/Binary_Search.mdx +++ b/content/4_Silver/Binary_Search.mdx @@ -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