Question: 1. Write code in C++ implementing Selection Sort. Your program should let the user enter how large of an array they wish to sort, followed
1. Write code in C++ implementing Selection Sort. Your program should let the user enter how large of an array they wish to sort, followed by the values they wish to be in the array. It should print the unsorted and sorted array. Start with the bubblesort example from class/notes and replace the bubblesort function with a select sort function.
proceedure SelectionSort(array a, length(A) = n)
for i in 0 to n - 2
maxIndex = i
for j in (i + 1) to (n - 1)
if a[j] > A[maxIndex]
maxIndex = j
tmp = A[i]
A[i] = A[maxIndex]
A[maxIndex] = tmp
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
