add correctness check
This commit is contained in:
parent
8c3d30f6f6
commit
66f5b09849
2 changed files with 6 additions and 2 deletions
|
@ -47,7 +47,8 @@ fn main() -> io::Result<()> {
|
|||
println!("start state: {:?}", input_list);
|
||||
println!("end state: {:?}", list);
|
||||
let mut insertion = InsertionSort::new(false);
|
||||
println!("sorted array: {:?}", insertion.sort(&input_list));
|
||||
let sorted = insertion.sort(&input_list);
|
||||
println!("sorted array: {:?}", sorted);
|
||||
let ordinal_indicator = match order_statistic {
|
||||
1 => "st",
|
||||
2 => "nd",
|
||||
|
@ -55,6 +56,7 @@ fn main() -> io::Result<()> {
|
|||
_ => "th",
|
||||
};
|
||||
println!("{}{} order statistic: {}", order_statistic, ordinal_indicator, result);
|
||||
println!("is correct: {}", result == sorted[order_statistic - 1]);
|
||||
}
|
||||
|
||||
println!("swaps: {}", randomized.num_swap());
|
||||
|
|
|
@ -47,7 +47,8 @@ fn main() -> io::Result<()> {
|
|||
println!("start state: {:?}", input_list);
|
||||
println!("end state: {:?}", list);
|
||||
let mut insertion = InsertionSort::new(false);
|
||||
println!("sorted array: {:?}", insertion.sort(&input_list));
|
||||
let sorted = insertion.sort(&input_list);
|
||||
println!("sorted array: {:?}", sorted);
|
||||
let ordinal_indicator = match order_statistic {
|
||||
1 => "st",
|
||||
2 => "nd",
|
||||
|
@ -55,6 +56,7 @@ fn main() -> io::Result<()> {
|
|||
_ => "th",
|
||||
};
|
||||
println!("{}{} order statistic: {}", order_statistic, ordinal_indicator, result);
|
||||
println!("is correct: {}", result == sorted[order_statistic - 1]);
|
||||
}
|
||||
|
||||
println!("swaps: {}", normal.num_swap());
|
||||
|
|
Loading…
Reference in a new issue