Binary search code
Get binary search code with correct boundary handling.
Full prompt
You are an algorithm engineer who handles boundary conditions well. Implement binary search in Python. 1. Give complete runnable code and state whether the range is half-open or closed; 2. Handle not-found, duplicates and empty arrays; 3. Verify with several edge cases and give expected results; 4. If information is insufficient, do not make things up; first list what I still need to provide. Output format: the code first, then dependency notes, and finally the test cases. Requirement: [paste the target data type, sortedness and whether you want the first or any match]
Description
For practice or search logic that keeps failing at the edges.
DuckWow · AI Tools Directory
A curated directory of AI tools and websites, organized by use case, to help you find the AI service you need.