Title: fix: improve binary search mid calculation to avoid overflow by satish-sharma360 · Pull Request #1891 · TheAlgorithms/JavaScript · GitHub
Open Graph Title: fix: improve binary search mid calculation to avoid overflow by satish-sharma360 · Pull Request #1891 · TheAlgorithms/JavaScript
X Title: fix: improve binary search mid calculation to avoid overflow by satish-sharma360 · Pull Request #1891 · TheAlgorithms/JavaScript
Description: Describe your change: Add an algorithm? Fix a bug or typo in an existing algorithm? Documentation change? Improved the binary search implementation by updating the mid calculation. Old approach: mid = Math.floor((low + high) / 2) New approach: mid = low + Math.floor((high - low) / 2) This prevents potential overflow issues and follows best practices used in production-level code. Checklist: I have read CONTRIBUTING.md This pull request is all my own work -- I have not plagiarized. I know that pull requests will not be merged if they fail the automated tests. This PR only changes one algorithm file. All new JavaScript files are placed inside an existing directory. All filenames follow PascalCase naming convention. Added reference URL in comments.
Open Graph Description: Describe your change: Add an algorithm? Fix a bug or typo in an existing algorithm? Documentation change? Improved the binary search implementation by updating the mid calculation. Old approac...
X Description: Describe your change: Add an algorithm? Fix a bug or typo in an existing algorithm? Documentation change? Improved the binary search implementation by updating the mid calculation. Old approac...
Opengraph URL: https://github.com/TheAlgorithms/JavaScript/pull/1891
X: @github
Domain: Github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:f719c78c-cd88-9ebd-40e2-0c583bad5b92 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 8C96:22E2E4:1329B8F:1B79B24:6A634585 |
| html-safe-nonce | 0c0faca71eccded516e2d21c1b8373356b22486204eae9e8e7bd7eb23f05c11f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4Qzk2OjIyRTJFNDoxMzI5QjhGOjFCNzlCMjQ6NkE2MzQ1ODUiLCJ2aXNpdG9yX2lkIjoiMzI3MDE3NjM5NzE3MzQwOTE1NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | aaae1c03999929653f518df308f0bc00e0f53d6aa2324962d4d3433890ce7610 |
| hovercard-subject-tag | pull_request:3502989257 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/TheAlgorithms/JavaScript/pull/1891/files |
| twitter:image | https://avatars.githubusercontent.com/u/135573281?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/135573281?s=400&v=4 |
| og:image:alt | Describe your change: Add an algorithm? Fix a bug or typo in an existing algorithm? Documentation change? Improved the binary search implementation by updating the mid calculation. Old approac... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 59e55daad7174ca59d63c6974d58276ccb5477442e550bebb3c035e1bef11c94 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/TheAlgorithms/JavaScript git https://github.com/TheAlgorithms/JavaScript.git |
| octolytics-dimension-user_id | 20487725 |
| octolytics-dimension-user_login | TheAlgorithms |
| octolytics-dimension-repository_id | 97086543 |
| octolytics-dimension-repository_nwo | TheAlgorithms/JavaScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 97086543 |
| octolytics-dimension-repository_network_root_nwo | TheAlgorithms/JavaScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 990295d92a4cc7b63fbbd83a046217cd7d77d49c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width