all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Theodor Thornhill <theo@thornhill.no>
To: Yuan Fu <casouri@gmail.com>
Cc: emacs-devel <emacs-devel@gnu.org>,
	Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Re: Tree-sitter indentation for js-mode & cc-mode
Date: Fri, 28 Oct 2022 10:59:22 +0200	[thread overview]
Message-ID: <87pmecgw7p.fsf@thornhill.no> (raw)
In-Reply-To: <425E0075-3F44-4832-BA2E-61E7D0A26FF4@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1436 bytes --]

Yuan Fu <casouri@gmail.com> writes:

>> 
>>>> looking up way to much the root of the tree, but you know the internals
>>>> here better than me.  Is this something we can optimize away? See the
>>>> attached report at the bottom.
>>> 
>>> This is very strange, I need to look into it.
>>> 
>> 
>> I'm happy to provide more info and profiling, as well as testing if
>> need be!
>
> I just tried running treesit-buffer-root-node and treesit-node-at
> 10000 times in the end of buffer and they are pretty fast, so I don’t
> know why the benchmark says 99% time is spent in
> treesit-buffer-root-node. Could you share the benchmark code and test
> file? Thanks!

Absolutely.  I ran the test again - see test file and new report in
attachments.

You need to `M-x eval-buffer` in `treesit.el` to avoid the compiled
functions to get better profile report, then in the testfile:

M-x profiler-start
C-x h ;; (mark-whole-buffer)
C-i   ;; (indent-for-tab-command)
;; --- waaaaait
M-x profiler-stop
M-x profiler-report

There's no test code for this, just running the commands sequentially
and get the report :-)

Are we parsing the whole file over and over in treesit-buffer-root-node?
Do we for some reason not hit the early return?

Code is taken from [0] and duplicated and messed up indentation.

Theo

[0] https://raw.githubusercontent.com/TheAlgorithms/JavaScript/master/Search/BinarySearch.js


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: foo.js --]
[-- Type: text/javascript, Size: 1653341 bytes --]


function binarySearchRecursive (arr, x, low = 0, high = arr.length - 1) {
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
const mid = Math.floor(low + (high - low) / 2)

if (high >= low) {
if (arr[mid] === x) {
// item found => return its index
return mid
}

if (x < arr[mid]) {
// arr[mid] is an upper bound for x, so if x is in arr => low <= x < mid
return binarySearchRecursive(arr, x, low, mid - 1)
} else {
// arr[mid] is a lower bound for x, so if x is in arr => mid < x <= high
return binarySearchRecursive(arr, x, mid + 1, high)
}
} else {
// if low > high => we have searched the whole array without finding the item
return -1
}
}

[-- Attachment #3: cpu.txt --]
[-- Type: text/plain, Size: 18577 bytes --]

      177699  99% - command-execute
      177652  99%  - funcall-interactively
      177652  99%   - indent-for-tab-command
      177652  99%    - indent-region
      177628  99%     - indent-region-line-by-line
      177516  99%      - indent-according-to-mode
      177504  99%       - treesit-indent
      177484  99%        - let*
      174145  97%         - cond
      174125  97%          - treesit-node-at
      174109  97%           - let*
      174101  97%            - if
      173969  97%             - treesit-buffer-root-node
      173961  97%              - let*
      173957  97%                 if
         132   0%             - progn
         120   0%              - while
         120   0%                 setq
           8   0%                if
           4   0%          - eq
           4   0%             length
        3179   1%         - let*
        2488   1%          - funcall
        2476   1%           - treesit-simple-indent
        2468   1%            - if
        2456   1%             - let*
        2372   1%              - let*
        2356   1%               - while
        2328   1%                - and
        2320   1%                 - progn
        2260   1%                  - if
        1940   1%                   - treesit--simple-indent-eval
        1904   1%                    - cond
        1872   1%                     - apply
        1260   0%                      - treesit--simple-indent-eval
        1248   0%                       - cond
        1220   0%                        - apply
        1080   0%                         - #<lambda 0xad78144b4804>
         772   0%                          - `
         572   0%                           - #<compiled 0x1b3181fd1560e638>
         536   0%                            - backquote-process
         392   0%                             - backquote-process
         148   0%                              - backquote-process
          68   0%                                 backquote-process
           8   0%                                 backquote-listify
          12   0%                                backquote-listify
         176   0%                           - list
          32   0%                            - backquote-list*
          12   0%                               cons
          40   0%                         - treesit--simple-indent-eval
          24   0%                          - cond
           4   0%                             and
          36   0%                         - mapcar
          28   0%                          - treesit--simple-indent-eval
          20   0%                             cond
          12   0%                        - and
           4   0%                           not
         224   0%                      - mapcar
         160   0%                       - treesit--simple-indent-eval
         144   0%                        - cond
           4   0%                           and
           4   0%                      - #<lambda 0xb2d191f7d7356>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d7356>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7cc38e>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d7356>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d7356>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7cc38e>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7cc38e>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7cc38e>
           4   0%                         string-match-p
           4   0%                      - #<lambda 0xb2d191f7d74cd>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7cc38e>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d7707>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7cc38e>
           4   0%                         string-match-p
           4   0%                      - #<lambda 0xb2d191f7d74cd>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7cc38e>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d7707>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7cc38e>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d77c1>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7cc38e>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d77c1>
           4   0%                         string-match-p
           4   0%                      - #<lambda 0xb2d191f7d7707>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d74cd>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d77c1>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d77c1>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d77c1>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7cc38e>
           4   0%                         string-match-p
           4   0%                      - #<lambda 0xb2d191f7cc38e>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d77c1>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d74cd>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7cc38e>
           4   0%                         string-match-p
           4   0%                      - #<lambda 0xb2d191f7cc38e>
           4   0%                         string-match-p
           4   0%                      - #<lambda 0xb2d191f7cc38e>
           4   0%                         string-match-p
           4   0%                      - #<lambda 0xb2d191f7cc38e>
           4   0%                         string-match-p
           4   0%                      - #<lambda 0xb2d191f7cc38e>
           4   0%                         string-match-p
           4   0%                      - #<lambda 0xb2d191f7d74cd>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d74cd>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7cc38e>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7cc38e>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d77c1>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d74cd>
           4   0%                         string-match-p
           4   0%                      - #<lambda 0xb2d191f7cc38e>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d7356>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                        #<lambda 0xb2d191f7cc38e>
           4   0%                      - #<lambda 0xb2d191f7d7356>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                        #<lambda 0xb2d191f7cc38e>
           4   0%                      - #<lambda 0xb2d191f7cc38e>
           4   0%                         string-match-p
           4   0%                      - #<lambda 0xb2d191f7d77c1>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d77c1>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d7707>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d77c1>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d74cd>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7cc38e>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d7707>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7cc38e>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                        #<lambda 0xb2d191f7cc38e>
           4   0%                      - #<lambda 0xb2d191f7d74cd>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                        #<lambda 0xb2d191f7cc38e>
           4   0%                      - #<lambda 0xb2d191f7d7356>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d7707>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7cc38e>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d74cd>
           4   0%                         string-match-p
           4   0%                      - #<lambda 0xb2d191f7d77c1>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d74cd>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7cc38e>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d77c1>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d7707>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7cc38e>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d77c1>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d77c1>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d7356>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d74cd>
           4   0%                         string-match-p
           4   0%                      - #<lambda 0xb2d191f7d7356>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d7707>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d74cd>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d7356>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                      - #<lambda 0xb2d191f7d7356>
           4   0%                       - string-match-p
           4   0%                          or
           4   0%                       and
         292   0%                   - progn
         288   0%                    - progn
         276   0%                     - setq
         252   0%                      - let
         232   0%                       - treesit--simple-indent-eval
         224   0%                        - cond
         212   0%                         - apply
         140   0%                          - #<lambda 0x86706eb2bdc1d3>
          96   0%                           - save-excursion
           4   0%                              goto-char
          40   0%                          - mapcar
          24   0%                           - treesit--simple-indent-eval
          24   0%                              cond
          16   0%                          - treesit--simple-indent-eval
           8   0%                             cond
           4   0%                           and
           8   0%                         cons
          32   0%                    setq
           4   0%                  setq
           4   0%                treesit-node-language
         643   0%          - progn
         631   0%           - let*
         623   0%            - let
         623   0%             - if
         623   0%              - let
         483   0%               - if
          67   0%                - indent-line-to
          39   0%                 - #<compiled -0x18b4777d062e6ec>
          39   0%                  - filter-buffer-substring
          39   0%                   - buffer-substring--filter
          39   0%                    - #<compiled -0xf7ff5b55e48322>
          39   0%                       apply
         132   0%               - +
         120   0%                  save-excursion
          32   0%            cond
         104   0%         - treesit-parent-while
          80   0%          - let
          76   0%           - while
          48   0%            - progn
          44   0%               setq
          16   0%            - and
           8   0%             - funcall
           8   0%              - #<lambda 0x126956a6393a5198>
           4   0%                 eq
          20   0%           save-excursion
          47   0%  - byte-code
          47   0%   - read-extended-command
          47   0%    - read-extended-command-1
          47   0%     - completing-read-default
          47   0%      - apply
          47   0%       - vertico--advice
          31   0%        - #<subr completing-read-default>
          20   0%         - vertico--exhibit
          20   0%          - vertico--update
          20   0%           - vertico--recompute
          16   0%            - vertico--all-completions
          16   0%             - completion-all-completions
          16   0%              - completion--nth-completion
          16   0%               - completion--some
          16   0%                - #<compiled -0x1183ac11f303aafc>
          16   0%                 - completion-basic-all-completions
          16   0%                  - completion-pcm--all-completions
          16   0%                   - #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_54>
          16   0%                    - complete-with-action
           8   0%                     - all-completions
           8   0%                      - #<compiled 0x21876cdf4622255>
           8   0%                         #<compiled 0x85106f9909cd18a>
           4   0%              vertico-sort-history-length-alpha
           7   0%         - frame-windows-min-size
           7   0%          - window-min-size
           7   0%           - window--min-size-1
           7   0%              window--min-size-1
        1298   0% + ...
          35   0% + #<compiled -0x18b4777d062e6ec>
          28   0% + timer-event-handler
          23   0% + redisplay_internal (C function)

  reply	other threads:[~2022-10-28  8:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-27  1:43 Tree-sitter indentation for js-mode & cc-mode Yuan Fu
2022-10-27  9:11 ` Theodor Thornhill
2022-10-27  9:28   ` Theodor Thornhill
2022-10-27  9:58     ` Theodor Thornhill
2022-10-27 15:21   ` Yuan Fu
2022-10-27 18:36     ` Theodor Thornhill
2022-10-28  8:15       ` Yuan Fu
2022-10-28  8:59         ` Theodor Thornhill [this message]
2022-10-28  9:10         ` Theodor Thornhill
2022-10-28 19:43           ` Yuan Fu
2022-10-28 19:49             ` Theodor Thornhill
2022-10-29  1:05               ` Yuan Fu
2022-10-29  5:53             ` Eli Zaretskii
2022-10-29  6:54               ` Yuan Fu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pmecgw7p.fsf@thornhill.no \
    --to=theo@thornhill.no \
    --cc=casouri@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.