CPP-Programs- icon indicating copy to clipboard operation
CPP-Programs- copied to clipboard

Update BucketSort.cpp

Open YudhveerCAIN opened this issue 1 year ago • 0 comments

Switched to std::vector: Replaced the dynamic array float arr[n] with std::vector to properly handle runtime-determined sizes in C++. Bucket Index Adjustment: Added a check to ensure that values outside the range [0, 1) don’t cause out-of-bounds errors in the bucket index calculation. Improved Efficiency: Instead of using erase in the loop (which slows things down), I now iterate through the bucket and directly assign sorted values to the array. Added Input Validation: Included checks to ensure that all input values are between 0 and 1, making the program more robust against invalid inputs.

YudhveerCAIN avatar Oct 16 '24 18:10 YudhveerCAIN