Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

what are the defintions of these prototypes int findminidx(string scientist[], i

ID: 3783866 • Letter: W

Question

what are the defintions of these prototypes int findminidx(string scientist[], int i, int length); void swap(string scientist[], int i, int indexOfSmallest); void selectionSort(string scientist[], int length); for this code #include #include using namespace std; int findminidx(string scientist[], int length); void swap(string scientist[], int i, int indexOfSmallest); void selectionSort(string scientist[], int length); int main() { string scientist[7] = { "Newton", "Pascal", "Euler", "Gauss", "Bayes", "Fibonacci", "Turing" }; cout << scientist[0] << endl; cout << scientist[findminidx(scientist, 7)]; cout<

Explanation / Answer

PROGRAM CODE:

#include <iostream>

using namespace std;
int findminidx(string scientist[], int length)
{
   string value = scientist[0];
   int index = 0;
   for(int i=1; i<length; i++)
   {
       if(value > scientist[i])
       {
           value = scientist[i];
           index = i;
       }
   }
   return index;
}

void swap(string scientist[], int i, int indexOfSmallest)
{
   string temp = scientist[i];
   scientist[i] = scientist[indexOfSmallest];
   scientist[indexOfSmallest] = temp;
}

void selectionSort(string scientist[], int length)
{
   string min, temp;
   int loc;
   for(int i=0; i<length-1; i++)
{
min=scientist[i];
loc=i;
for(int j=i+1;j<length;j++)
{
if(min>scientist[j])
{
min=scientist[j];
loc=j;
}
}

temp=scientist[i];
scientist[i]=scientist[loc];
scientist[loc]=temp;
}
}

int main()
{
   string scientist[7] = { "Newton", "Pascal", "Euler", "Gauss", "Bayes", "Fibonacci", "Turing" };
   cout << scientist[0] << endl;
   cout << scientist[findminidx(scientist, 7)];
  
   return 0;
}

Please find the definitions for the three prototypes above.