Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Search/BinarySearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
*/

function binarySearchRecursive(arr, x, low = 0, high = arr.length - 1) {
const mid = Math.floor(low + (high - low) / 2)
// Using optimized mid calculation to prevent overflow
const mid = low + Math.floor((high - low) / 2);

if (high >= low) {
if (arr[mid] === x) {
Expand Down
Loading