1.7 KiB
1.7 KiB
slug | title | author | order | prerequisites | ||
---|---|---|---|---|---|---|
/silver/binary-search | Binary Search | Nathan Chen | 4 |
|
Binary search can be used on monotonic functions for a logarithmic runtime.
The Basic Application
Find an element in a sorted array in O(log N) time.
Tutorial
Library Functions to do Binary Search:
Java
C++
Problems
Binary Searching on the Answer
Oftentimes used when you need to find the minimum or maximum of some quantity such that it satisfies some property.
Tutorial
Problems
- USACO Silver Cownvention
- USACO Silver Cow Dance
- USACO Silver Social Distancing
- USACO Silver Loan Repayment
- Also needs some math and "sqrt" analysis
- USACO Silver Angry Cows