Given pseudocode for a famous sorting algorithm below-called bubble sort
function BUBBLESORT(A)
Set n to be length of A
Set swapped = True
while swapped do
Set swapped = False
for i = 1, i < n, i++ do
if A[i - 1] > A[i] then
Swap A[i - 1] and A[i]
Set swapped = True
end if
end for
end while
end function
Implement this algorithm in c
// function prototype
#include <stdio.h>
int main()
{
int Array [] = {3,1,45,7,12,11,8,4,5,6};
// print array before sorting
// call function bubble sort here
//print array after sorting
return 0;
}
Exercise 2[5 marks]: change the algorithm above to sort the algorithm in reverse order