Objective
Sort a in place with selection sort and return the exact number of comparisons between array elements that the sort performed.
Steps
$ sort_cost(a, 5) with a = {3, -1, 7, 0, -4}
cost=10 [-4, -1, 0, 3, 7]
$ sort_cost(a, 8) with a = {8, 7, 6, 5, 4, 3, 2, 1}
cost=28 [1, 2, 3, 4, 5, 6, 7, 8]
$ sort_cost(a, 0) with a = {5, 3}
cost=0 [5, 3]
$ sort_cost(a, 100) with a filled by the harness
cost=4950 first=679 last=63337 sum=3246985 sorted=yes
$ sort_cost at n = 10, 100, 1000, 10000
n=10 cost=45 n=100 cost=4950 n=1000 cost=499500 n=10000 cost=49995000
Expected files
Allowed functions
None. Write every helper yourself.
Allowed headers

Objective
Sort a in place with selection sort and return the exact number of comparisons between array elements that the sort performed.
Steps
$ sort_cost(a, 5) with a = {3, -1, 7, 0, -4}
cost=10 [-4, -1, 0, 3, 7]
$ sort_cost(a, 8) with a = {8, 7, 6, 5, 4, 3, 2, 1}
cost=28 [1, 2, 3, 4, 5, 6, 7, 8]
$ sort_cost(a, 0) with a = {5, 3}
cost=0 [5, 3]
$ sort_cost(a, 100) with a filled by the harness
cost=4950 first=679 last=63337 sum=3246985 sorted=yes
$ sort_cost at n = 10, 100, 1000, 10000
n=10 cost=45 n=100 cost=4950 n=1000 cost=499500 n=10000 cost=49995000
Expected files
Allowed functions
None. Write every helper yourself.
Allowed headers

Tests
Run the tests to grade your code