Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In part one, you are going to implement the selection sort function that is capable of sorting vectors of int, double or string. In part

image text in transcribed

In part one, you are going to implement the selection sort function that is capable of sorting vectors of int, double or string. In part two you will be writing a try catch block to catch the out-of-range exception. You are to write three functions and manipulate main) function for this lab all of which should be written in one main.cpp file: Part one 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 therm 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 Part two T getElement (vector vals, int index) : Passes in a vector of type T (T could be string, double or int) and an index of type int. The function returns the element located at the index of the vals. You should write up a try catch block in main function so that when the index is out of the range of the vector, the "std:outofrange" exception will be caught by the catch (const stdoutofrange& excpt). Once the exception is caught, it should output 'out of range exception occured followed by a new line. You are given a function that creates a vector of characters with random size. You just need to put the following piece of code in your main.cpp file as is vector createvector () { int ve csize rand() % 26; char c = 'a'; vector vals; for (int = 0; i library in your program which contains definitions for a set of standard exceptions. int main ) /Part B srand (time (0)) vector vals - cra tevector() ; char curChar int index; int numotRuns 1o while(--numOfRuns >-0) cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Annoyance about a statement that has been made by somebody

Answered: 1 week ago