Skip to content

EliahKagan/bounds

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bounds - lower and upper bound binary search

Classic binary search returns an index when an equivalent item is found, or a special value if no equivalent item is present.

It can be more useful to use forms of binary search that return either he lowest or highest index at which the item could be inserted while still maintaining a sorted array. (Strictly speaking, it is maintaining an array that is partitioned with respect to the new item. That weaker criterion is sufficient, and it is not necessary that the data be fully sorted.)

The best way to achieve this varies by language. This shows some demonstration code in Python, C++, and Java:

License

0BSD. See LICENSE.

See also

Binary Search - A Different Perspective | Python Algorithms
by mCoding (James Murphy)

About

lower and upper bound binary search

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published