williamfiset / Algorithms

A collection of algorithms and data structures
MIT License
17.18k stars 4.34k forks source link

Refactored the BinarySearch.Java file #370

Open kbashadal opened 1 year ago

kbashadal commented 1 year ago

…name method/variable refactoring**

2. Renamed the EPS constant to EPSILON to improve readability.-->**Introduce explaining variable refactoring**
3. Added Javadoc comments for the binarySearch method to improve documentation.
4. Changed the IllegalArgumentException message to make it more clear.
5. Changed the name of the function used in the first example from function to squareFunction to make it more descriptive.
6. Added a comment to indicate that any function can be used for the binary search.
7. Added a comment to explain that the second example is not practical but serves as an illustration.
8. Used Math.PI instead of a hardcoded value for pi in the second example.