Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Practice Problem (1.2) Write a function template named 'insertionSort which takes a single type template parameter that specifies the data type of its elements. The
Practice Problem (1.2) Write a function template named 'insertionSort which takes a single type template parameter that specifies the data type of its elements. The function has two input formal parameters: an array of elements whose type is supplied as a template parameter, and the array size. The function sorts the elements in the array in ascending order using "Insertion Sorting Algorithm". The function prints the elements of the resulting sorted array with one blank space between every two elements printed. The function returns no value. (Hint: in the case of sorting an array of characters, sorting is performed by comparing ASCII codes of the characters) Then, write a complete C+ program (i.e. with a main function) to demonstrate the use of inser- tionSort to sort and print the following arrays declared below: const int intSize 7 const int floatSize9 const int charSize27 int intArr[intSize10, 33, -23, 33, 56, 778, 22; float floatArr(floatSize] = (9.33, -18.44, 18.5, 9.44, 2, 78, -1, -48.45, 65.8); char charArr[charSize]"MNBVZXCASDFGHJKLPOIUYTREWQ"; //every string literal terminates with null character 10 The output of your program should print results similar to the following: OUTPUT: Sorting and printing intArr using funtion template with int type: -23 10 22 33 33 56 778 Sorting and printing floatArr using funtion template with float type: -40.45 -10.4410 2 9.33 9.44 10.5 65.8 78 Sorting and printing charArr using funtion template with char type: Activate A B CD EFGH I J K LMN0 PQRST UVW X Y Z
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started