0

So, I'm merely just a student learning and all that. The assignment has four components: write a bubble sort function with test program, write a quick sort function with a test program, write a shell sort function with a test program, then finally write a main program. For each compare in the array, it'll cost a unit, and for each swap costing 6.

```
#include <iostream>
#include <stdlib.h>
#define N 20
using namespace std;
int bsort(int Ar[], int count, int swc)
{
int swaps;
swaps = 1;
while(swaps)
{
swaps = 0;
for (int i = 0; i < N - 1; i++)
{
count++;
if (Ar[i] > Ar[i + 1])
{
swap(Ar[i], Ar[i + 1]);
swaps = 1;
swc += 6;
}
}
}
return count;
return swc;
}
#if __INCLUDE_LEVEL__ < 1
int main()
{
int Ar[N], count, swc;
for (int i = 0; i < N; i++){Ar[i] = rand() % 100;}
for (int x = 0; x < N; x++){cout << bsort(&Ar[x], count, swc) << endl;}
}
#endif
```

I know that there's an issue with processing all that, but I'm really unclear as to how to get that done - to be able to sort the array and get the costs for the compares and swaps. I'm sorry if I seem very.. unintelligent about it.