#sorting #bubble #cookbook #davidkim

yanked bubble-sort-davidkim

A quick and non-optimized, cloning version of the bubble sort algorithm. Created as a showcase for publishing crates in the Rust Cookbook 2018

0.1.0 Mar 7, 2022

#10 in #cookbook

MIT license

4KB

Bubble Sort

A non-optimal implemenation of the bubble sort algorithm. Best case runtime is O(n) - worst case O(n^2). Read more on wikipedia.

This crate was published to support a new version of the Rust Cookbook published by Packt Publishing and written by Claus Matzinger.

Source code until the book is published

License

MIT


lib.rs:

This is a non-optimized implementation of the bubble sort algorithm for the book Rust Cookbook by Packt. This implementation also clones the input vector.

Examples

 let v = vec![2, 2, 10, 1, 5, 4, 3]; 
 assert_eq!(bubble_sort(&v), vec![1, 2, 2, 3, 4, 5, 10]);

No runtime deps