Title: fix: correct Fisher-Yates shuffle bias in bogoSort (#1867) by ayushchaudhari562 · Pull Request #1899 · TheAlgorithms/JavaScript · GitHub
Open Graph Title: fix: correct Fisher-Yates shuffle bias in bogoSort (#1867) by ayushchaudhari562 · Pull Request #1899 · TheAlgorithms/JavaScript
X Title: fix: correct Fisher-Yates shuffle bias in bogoSort (#1867) by ayushchaudhari562 · Pull Request #1899 · TheAlgorithms/JavaScript
Description: Describe your change: Add an algorithm? Fix a bug or typo in an existing algorithm? Documentation change? Description: Fixes #1867 This PR addresses the mathematical bias and off-by-one errors in the shuffle function inside the bogoSort implementation. Corrected the loop bounds so that the last element of the array is no longer skipped during the shuffle process. Updated the random index generation range from [0, i) to [0, i] by using Math.random() * (i + 1). This ensures an unbiased Fisher-Yates shuffle where elements are allowed to swap with themselves, restoring proper uniform distribution. Updated the code to use clean, modern ES6 array destructuring for the variable swapping logic. 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. To ease review, please open separate PRs for separate algorithms. All new JavaScript files are placed inside an existing directory. All filenames should use the UpperCamelCase (PascalCase) style. There should be no spaces in filenames. Example: UserProfile.js is allowed but userprofile.js, UserProfile.js , user-Profile.js, user_profile.js are not All new algorithms have a URL in their comments that points to Wikipedia or another similar explanation. If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.
Open Graph Description: Describe your change: Add an algorithm? Fix a bug or typo in an existing algorithm? Documentation change? Description: Fixes #1867 This PR addresses the mathematical bias and off-by-one errors...
X Description: Describe your change: Add an algorithm? Fix a bug or typo in an existing algorithm? Documentation change? Description: Fixes #1867 This PR addresses the mathematical bias and off-by-one errors...
Opengraph URL: https://github.com/TheAlgorithms/JavaScript/pull/1899
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:0ef8f354-a296-c8cf-a70f-f5e415618e42 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 8E32:11247E:10C3C8A:180E939:6A633A44 |
| html-safe-nonce | 88f68b508323dd1acfac3f91a4b5e68389434601107b02a0a425bf72bbd61fd3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RTMyOjExMjQ3RToxMEMzQzhBOjE4MEU5Mzk6NkE2MzNBNDQiLCJ2aXNpdG9yX2lkIjoiOTc1NDMyNTI0MDUwNDE0MTQ4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 0f0fa01f9b0780c03a54eca9678fdefcb96df6089b36c91691b0c7c9b900b11a |
| hovercard-subject-tag | pull_request:3716664597 |
| 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/1899/files |
| twitter:image | https://avatars.githubusercontent.com/u/240131432?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/240131432?s=400&v=4 |
| og:image:alt | Describe your change: Add an algorithm? Fix a bug or typo in an existing algorithm? Documentation change? Description: Fixes #1867 This PR addresses the mathematical bias and off-by-one errors... |
| 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