Using pseudo-code (computer instructions written in plain english) outline the steps to take an array of variable size and order the contents from highest to lowest.
http://www.personal.kent.edu/~rmuhamma/Algorithms/MyAlgorithms/Sorting/insertionSort.htm said:void insertionSort(int numbers[], int array_size)
{
int i, j, index;
for (i=1; i < array_size; i++)
{
index = numbers;
j = i;
while ((j > 0) && (numbers[j-1] > index))
{
numbers[j] = numbers[j-1];
j = j - 1;
}
numbers[j] = index;
}
}
Line 1: Accepts arguments where arr is the array to be sorted, beg is the beginning of the segment to be sorted, and end is the end of the segment to be sorted.Quicksort said:void sort(int arr[], int beg, int end)
{
if (end > beg + 1)
{
int piv = arr[beg], L = beg + 1, r = end;
while (L<R)
{
if (arr[L] <= piv)
L++;
else
swap(&arr[L], &arr[--r]);
}
swap(&arr[--L], &arr[beg]);
sort(arr, beg, L);
sort(arr, r, end);
}
}