Title: fix(searches): fix boundary safety and null checks in SaddlebackSearch by hardikkaurani · Pull Request #7726 · TheAlgorithms/Java · GitHub
Open Graph Title: fix(searches): fix boundary safety and null checks in SaddlebackSearch by hardikkaurani · Pull Request #7726 · TheAlgorithms/Java
X Title: fix(searches): fix boundary safety and null checks in SaddlebackSearch by hardikkaurani · Pull Request #7726 · TheAlgorithms/Java
Description: I have read CONTRIBUTING.md. This pull request is all my own work -- I have not plagiarized it. All filenames are in PascalCase. All functions and variable names follow Java naming conventions. All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations. All new algorithms include a corresponding test class that validates their functionality. All new code is formatted with clang-format -i --style=file path/to/your/file.java Description This pull request fixes boundary safety, null handling, visibility, and adds a convenience overload in SaddlebackSearch: Row & Column Boundary Safety: In find(int[][] arr, int row, int col, int key), the check previously only tested row < 0 || col >= arr[row].length. Passing row >= arr.length would trigger an ArrayIndexOutOfBoundsException when evaluating arr[row]. Furthermore, negative col values were not guarded against and would trigger ArrayIndexOutOfBoundsException on arr[row][col]. Added row >= arr.length, col < 0, and arr[row] == null guards before accessing row contents. Null Array Handling: Updated empty check from if (arr.length == 0) to if (arr == null || arr.length == 0) to avoid NullPointerException and consistently throw IllegalArgumentException. Method Visibility: Changed method modifier from package-private static int[] find to public static int[] find. Convenience Entrypoint: Added overloaded public static int[] find(int[][] arr, int key) that initiates search from the bottom-left corner (find(arr, arr.length - 1, 0, key)). Comprehensive Tests: Added unit tests in SaddlebackSearchTest for the convenience method, null arrays, out-of-bounds rows, negative column indices, and matrix with null rows.
Open Graph Description: I have read CONTRIBUTING.md. This pull request is all my own work -- I have not plagiarized it. All filenames are in PascalCase. All functions and variable names follow Java naming conventions. ...
X Description: I have read CONTRIBUTING.md. This pull request is all my own work -- I have not plagiarized it. All filenames are in PascalCase. All functions and variable names follow Java naming conventions. ...
Opengraph URL: https://github.com/TheAlgorithms/Java/pull/7726
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:d84d47e9-364e-4462-bcb7-b0673b53f204 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E89A:325E4:99C738:CFDBE2:6AFA94CB |
| html-safe-nonce | b78c54c911b1fd6b4cb7c7b45a000636c31fd597f251a543c06927f348013c72 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFODlBOjMyNUU0Ojk5QzczODpDRkRCRTI6NkFGQTk0Q0IiLCJ2aXNpdG9yX2lkIjoiNTQ5Mzc5MjQ1ODM1MTk1NTk1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | cfef965aa53dd03ebf0a6a954081d5210e55aabff877fd87e38d497e3bfc4aac |
| hovercard-subject-tag | pull_request:5115866382 |
| 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/Java/pull/7726/files |
| twitter:image | https://avatars.githubusercontent.com/u/224249943?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/224249943?s=400&v=4 |
| og:image:alt | I have read CONTRIBUTING.md. This pull request is all my own work -- I have not plagiarized it. All filenames are in PascalCase. All functions and variable names follow Java naming conventions. ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 612d3e6ffd693e7ea8d9fcf452370995872baef31d825b1fedef704cd3d24ac7 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/TheAlgorithms/Java git https://github.com/TheAlgorithms/Java.git |
| octolytics-dimension-user_id | 20487725 |
| octolytics-dimension-user_login | TheAlgorithms |
| octolytics-dimension-repository_id | 63477660 |
| octolytics-dimension-repository_nwo | TheAlgorithms/Java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 63477660 |
| octolytics-dimension-repository_network_root_nwo | TheAlgorithms/Java |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 072e34035c13c31543fba9f025cbbbda4210dae4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width