added demo in main for complete algos. started dijkstras

This commit is contained in:
specCon18 2024-05-17 12:37:13 -04:00
parent f895efce44
commit fc92909aec
10 changed files with 262 additions and 15 deletions

View file

@ -3,6 +3,12 @@
mod tests {
use super::bubble_sort;
#[test]
fn bubble_sort_primeagen_class_test(){
let mut arr = [9, 3, 7, 4, 69, 420, 42];
bubble_sort(&mut arr);
assert_eq!(arr,[3, 4, 7, 9, 42, 69, 420]);
}
#[test]
fn bubble_sort_already_sorted_input(){
let mut arr = [1, 2, 3, 4, 5];
bubble_sort(&mut arr);
@ -37,7 +43,7 @@ mod tests {
assert_eq!(arr, [42]);
}
}
fn bubble_sort(arr: &mut [usize]) {
pub fn bubble_sort(arr: &mut [usize]) {
let n = arr.len();
for i in 0..n {
for j in 0..n - 1 - i {