Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binary search function for collection or array #181

Open
daihan054 opened this issue Jan 26, 2022 · 2 comments
Open

Binary search function for collection or array #181

daihan054 opened this issue Jan 26, 2022 · 2 comments

Comments

@daihan054
Copy link

daihan054 commented Jan 26, 2022

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?

@xwu
Copy link
Contributor

xwu commented Jan 26, 2022

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

@Dhandeep10
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants