algos/src/main.rs

40 lines
869 B
Rust

mod merge_sort;
mod quick_sort;
mod util;
use crate::util::read_to_graph;
use crate::util::read_to_vector;
use crate::quick_sort::quick_sort;
use crate::merge_sort::merge_sort_inversions;
#[allow(dead_code)]
fn c1a2() {
let vec = read_to_vector("data/course_1_assignment_2.txt").unwrap();
let (_sorted, inversions) = merge_sort_inversions(vec);
println!("course 1 assignment 2: {:?}", inversions);
}
#[allow(dead_code)]
fn c1a3() {
let mut vec = read_to_vector("data/course_1_assignment_3.txt").unwrap();
let mut comp_acc: usize = 0;
quick_sort(&mut vec, &mut comp_acc);
println!("course 1 assignment 3: {:?}", comp_acc);
/*
1: 162085
2: 164123
3: 138382
*/
}
fn c1a4() {
let g = read_to_graph("data/course_1_assignment_4.txt").unwrap();
println!("{:?}", g);
}
fn main() {
// c1a2();
// c1a3();
c1a4();
}