Q5
Suppose we want to put an array of n integer numbers into descending numerical
order. This task is called sorting. One simple algorithm for sorting is selection sort.
You let an index i go from 0 to n-1, exchanging the ith element of the array with
the maximum element from i up to n. Using this finite set of integers as the input
array {4 3 9 6 1 7 0}:
i. Perform the asymptotic and worst-case analysis on the sorting algorithm
been implemented. (AN)10 marks
ii. Write or draw all the iterations in the selection sort process on the
array.(AP)5 marks
iii. Write a java or C++ code implementing the algorithm. (AP)

Respuesta :

The C++ code that would draw all the iterations in the selection sort process on the array is given below:

C++ Code

#include <stdio.h>

#include <stdlib.h>

int main() {

   int i, temp1, temp2;

   int string2[16] = { 0, 4, 2, 5, 1, 5, 6, 2, 6, 89, 21, 32, 31, 5, 32, 12 };

   _Bool check = 1;

   while (check) {

       temp1 = string2[i];

       temp2 = string2[i + 1];

       if (temp1 < temp2) {

           string2[i + 1] = temp1;

           string2[i] = temp2;

           i = 0;

       } else {

           i++;

           if (i = 15) {

               check = !check;

           }

       }

   }

   

   return 0;

}

Read more about C++ programming here:

https://brainly.com/question/20339175

#SPJ1