You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the bsearchIndex method is using slice, which creates a partial, shallow copy of the original array into a new array -- meaning it uses extra memory. This extra memory is unnecessary and will scale when handling large arrays. We can avoid this with simple manipulation of the starting and ending indexes ("i" and "j", respectively).
Moreover, instead of using recursion, this can be done with a loop which is actually more efficient.
Lastly, it will be helpful if this phrase is added in the docs: Use bsearchIndex or bsearch on arrays, assuming it is already sorted.
The text was updated successfully, but these errors were encountered:
Currently, the
bsearchIndex
method is usingslice
, which creates a partial, shallow copy of the original array into a new array -- meaning it uses extra memory. This extra memory is unnecessary and will scale when handling large arrays. We can avoid this with simple manipulation of the starting and ending indexes ("i" and "j", respectively).Moreover, instead of using recursion, this can be done with a loop which is actually more efficient.
Lastly, it will be helpful if this phrase is added in the docs:
Use
bsearchIndex
orbsearch
on arrays, assuming it is already sorted.The text was updated successfully, but these errors were encountered: