Skip to content
Snippets Groups Projects
Commit 5d8574a4 authored by dst1m17's avatar dst1m17
Browse files

Script to generate sorting times for bubble sort and quicksort algorithms across 5 replicates

parent dd4f2a23
Branches
No related tags found
No related merge requests found
#!/bin/bash
echo "Algorithm Array size,Time (ms)"
for i in {10..1000..10}; do
for j in {1..5}; do
num=$(shuf -i 0-10 -n 1);
if [[ $(shuf -i 0-5 -n 1) -gt 4 ]]
then
echo "Bubble sort" $i, $(($num + $(($i * $i))));
else
echo "Bubble sort" $i,$(($num + $(($i * $i))));
echo "DebugMsg: Bubble sort completed for array size " $i;
fi
if [[ $(shuf -i 0-5 -n 1) -gt 4 ]]
then
echo "Quicksort" $i,$(echo "$i $num" | awk '{printf "%1.4f\n",$2+$1*log($1)}')
else
echo "Quicksort" $i,$(echo "$i $num" | awk '{printf "%1.4f\n", $2+$1*log($1)}')
echo "DebugMsg: Quicksort completed for array size " $i;
fi
done
done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment