in program 3 you will implement a program to sort an int array using t

Question

In program #3, you will implement a program to sort an int array using two different sorting
algorithms. The main function for the program is given below. You will see that you have a hard-
coded array, a second array, the size of the array, and function calls to copy array1 into array2, to
sort and output array and to sort and output array2. The reason to make a copy of the array is that
the two sorts should work on the original, unsorted data, and after sort1 sorts array1, array1 is
changed, so we need a copy in array2. All access to the array, as you implement in the copy, sort1,
sort2 and output functions, must be solely through pointers and where you move down the array
to access its content solely through pointer arithmetic./nvoid main() {
int array1 []={10, 3, 6, 5, 9, 2, 1, 7, 4, 8);
int array2 [10];
int size=10;
copy (array1, array2, size);
sort1 (arrayl, size);
output (arrayl, size);
sort2 (array2, size);
output (array2, size);
}
The two sort functions will implement two of three different sorting algorithms (bubble sort,
selection sort, insertion sort). You are to select which two you want to implement. The three sorts
are described below in a C-like way although as there is no boolean in C, you would have to work
out how to modify the C code. Remember, you must access your arrays by pointer and pointer
arithmetic so you will not have notation like a[i] and instead use a pointer, and your for loops will
not iterate over numbers from 0 to n, but instead use a pointer and pointer arithmetic.
Bubble Sort
sorted=false;
k=n;
while (!sorted) {
sorted=true;
for (i=0; i<k-1; i++)
if (a[i]>a[i+1]) {
sorted=false;
temp=a[i];
a[i]=a[i+1];
a[i+1]=temp;/nSelection Sort
for (i=0; i<n-1; i++) {
minPosition=i;
}
Insert Sort
for(j=i+1; j<n; j++)
}
if (a[j]<a [minPosition])
minPosition=j;
temp-a [minPosition];
a [minPosition] =a[i];
a[i]=temp;
for (i=1;i<n;i++) {
temp=a[i];
location=i-1;
while (location>= 0 &&a [location] >temp) {
a [location+1] =a [location];
location--;
}
a [location+1] =temp;
In order to change the loops and array references to pointers, you will need to adapt code like the
following loop:
for (i=0;i<n;i++) printf("%d", a[i]);
into code like the following (where p is an int pointer, or int *p):
for (p=a; p<a+n;p++) printf("%d", *p);
In order to access a [i+1], you would use code like * (p+1).
You should only implement one .c file (you may place any # statements and function prototypes
into a header file if desired). Your program should have five functions, main, copy, sort1, sort2,
output. Once your program is working, change array1 to {10, 9, 8, 7, 6, 5, 4, 3, 2, 1} and rerun
your program. Collect both sets of output and paste them at the bottom of your source code in
comments and submit the one file.