swift-algorithms icon indicating copy to clipboard operation
swift-algorithms copied to clipboard

Binary search function for collection or array

Open daihan054 opened this issue 3 years ago • 2 comments

In c++ there has a stl function named as lower_bound which works as binary search. But in swift there has no such function. Could you please add it?

daihan054 avatar Jan 26 '22 15:01 daihan054

partitioningIndex(where:) is a slight generalization of a binary search, and is an O(log n) operation for random-access collections; O(n) otherwise.

xwu avatar Jan 26 '22 15:01 xwu

Hey! I got how to do this and have successfully written code for the required lower bound and upper bound. Can you please help me what i have to do to create a pull request? And where I have to paste this code. (as I am new to open source)

Dhandeep10 avatar Sep 14 '23 13:09 Dhandeep10