UTSAVS26 / PySnippets

Collection of reusable Python code snippets for all.
https://sites.google.com/view/pysnippets/
MIT License
13 stars 36 forks source link

[Feature Request]: Add Binary Search Algorithm to PySnippets #37

Open PeroxideParadox opened 3 days ago

PeroxideParadox commented 3 days ago

Is there an existing issue for this?

Feature Description

Description:

I propose adding a reusable Binary Search snippet to create a newAlgorithms category of PySnippets. Binary Search is a widely-used algorithm for searching in sorted arrays with a time complexity of O(log n), making it efficient for large datasets. This snippet will allow developers to quickly integrate a binary search function into their projects without reinventing the wheel, ensuring optimized performance for search operations in sorted data.

Why It's Useful:

Functionality:

The snippet will allow the user to search for an element in a sorted array and return its index, or -1 if not found. The function will handle both edge cases and invalid input, ensuring robust usage.

Test Cases:

Record

github-actions[bot] commented 3 days ago

🙌 Thank you for bringing this issue to our attention! We appreciate your input and will investigate it as soon as possible.

Feel free to join our community on Discord to discuss more!