Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BucketSort #750

Open
YudhveerCAIN opened this issue Oct 16, 2024 · 0 comments
Open

BucketSort #750

YudhveerCAIN opened this issue Oct 16, 2024 · 0 comments

Comments

@YudhveerCAIN
Copy link

  1. Dynamic Array Declaration: The program uses float arr[n], but this isn’t valid in standard C++ since arrays can't be dynamically sized this way. You should use std::vector instead to handle the dynamic size.
  2. Bucket Index Calculation: The code calculates the bucket index with int(size * array[i]), assuming all values are between 0 and 1. If any values fall outside this range, it could lead to out-of-bounds errors. You need to ensure the input values are within the expected range or scale them appropriately.
  3. Inefficient Element Removal: The program uses bucket[i].erase(bucket[i].begin()) repeatedly in a loop. This is inefficient because it shifts elements each time. A better approach is to iterate through the bucket and directly reassign values.
  4. Lack of Input Validation: The program doesn’t check if the user inputs valid values between 0 and 1. Adding validation helps prevent errors if someone enters an out-of-range number.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant