Question: C++ 16.6 Lab: Function Template In this lab you are going to implement a selection sort function that is capable of sorting vectors of int,

C++ 16.6 Lab: Function Template

In this lab you are going to implement a selection sort function that is capable of sorting vectors of int, double or string.

You are to write two functions both of which should be written in one main.cpp file:

unsigned min_index(const vector &vals, unsigned index): Passes in an index of type int and a vector of type T (T could be string, double or int). The function returns the index of the min value starting from "index" to the end of the "vector".

selection_sort(vector &vals): Passes in a vector of type T and sorts them based on the selection sort method. This function should utilize the min_index function to find the index of the min value in the unsorted portion of the vector.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!