Skip to content

Conversation

@Mahi-korrapati
Copy link

This pull request adds a complete and clear documentation file for the Bucket Sort algorithm.
The documentation explains the concept, steps, complexity, and provides a Rust code example aligned with the existing implementation in the repository.

@Mahi-korrapati
Copy link
Author

Hello!
I have added detailed documentation for the Bucket Sort algorithm.
Kindly review this PR and let me know if any changes are required.
Thank you for your time.

Comment on lines 20 to 43
## Rust Example

```rust
pub fn bucket_sort(arr: &mut [f32]) {
let n = arr.len();
let mut buckets: Vec<Vec<f32>> = vec![Vec::new(); n];

for &value in arr.iter() {
let index = (value * n as f32) as usize;
buckets[index.min(n - 1)].push(value);
}

for bucket in buckets.iter_mut() {
bucket.sort_by(|a, b| a.partial_cmp(b).unwrap());
}

let mut idx = 0;
for bucket in buckets {
for value in bucket {
arr[idx] = value;
idx += 1;
}
}
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this example please.

Suggested change
## Rust Example
```rust
pub fn bucket_sort(arr: &mut [f32]) {
let n = arr.len();
let mut buckets: Vec<Vec<f32>> = vec![Vec::new(); n];
for &value in arr.iter() {
let index = (value * n as f32) as usize;
buckets[index.min(n - 1)].push(value);
}
for bucket in buckets.iter_mut() {
bucket.sort_by(|a, b| a.partial_cmp(b).unwrap());
}
let mut idx = 0;
for bucket in buckets {
for value in bucket {
arr[idx] = value;
idx += 1;
}
}
}

@alexfertel
Copy link
Owner

😅 you removed the whole file...

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

Successfully merging this pull request may close these issues.

2 participants