String Selection Sort
Modify the selectionSort function presented in this chapter so it sorts an array of strings instead of an array of ints. Test the function with a driver
Program 8-8
#include <iostream>
#include <string>
using namespace std;
int main()
{
const int NUM_NAMES - 20;
string names[NUM NAMES] = {“Collins, Bill”, “Smith, Bart”, “Allen, Jim”,
“Griffin. Jim”, “Stamey, Marty”, “Rose, Geri”,
“Taylor, Terri”, “Johnson, Jill”.
“Allison, Jeff”, “Looney, Joe”, “Wolfe, Bill”,
“James, Jean”, “Weaver, Jim”, “Pore, Bob”,
“Rutherford, Greg”, “Javens, Renee”,
“Harrison, Rose”, “Setzer, Cathy”,
“Pike, Gordon”, “Holland, Beth” };
// Insert your code to complete this program
return 0;
}
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Starting Out with C++ from Control Structures to Objects (9th Edition)
Additional Engineering Textbook Solutions
Elementary Surveying: An Introduction To Geomatics (15th Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Introduction To Programming Using Visual Basic (11th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Java: An Introduction to Problem Solving and Programming (8th Edition)
Database Concepts (8th Edition)
- C++ Format Please Write a function called SortByUpper, that takes a vector of strings and changes that vector to be sorted according to only the uppercase letters in each string. No other characters should be involved in determining the order of the vector. For instance "zCAxT" < "aDyOG", because "CAT" < "DOG". No loops just STL alogorithms and iteratorsarrow_forwardIn C++ I need to compose a function that accepts an array of integer values as an argument and returns the total of the values in the arrayarrow_forwardmodule 4: Differentiate between Writing Functions for Array and Writing Functions for Structures.arrow_forward
- Programming Language: Python Limitations: Not allowed to use sklearn libraryarrow_forwardC++ code NB: Pointers must be usedarrow_forwardFunction Call Diagram Write a function call diagram showing this program. #include <stdio.h>#include <stdlib.h>#include <time.h> // function sum() -> Returns the sum of the elements of the arrayint sum(int array[]) { int i, sum = 0; for(i = 0; i < 5; i++) { sum += array[i]; // Summing up the elements } return sum; // Returning the sum} // function average() -> Returns the average of an arrayfloat average(int array[]) { int tot; float avg; tot = sum(array); // Calling the function sum() -> To get the sum of the elements of the array avg = tot / 5.0; // Computing the average return avg; // Returning the average} int main() { int a[5][5]; // 2-D array int i, j; int row[5]; // To store each row of the 2-D array float avg[5]; // To store the average of each of the 5 rows of the 2-D array int d1[5], d2[5]; // To store the diagonals of the 2-D array int sumD1, sumD2; // To store the sum of the 2 diagonals of the 2-D array srand(time(0)); for(i = 0; i…arrow_forward
- Huffman code // C program for Huffman Coding #include<stdio.h> #include<stdlib.h> #define MAX_TREE_HT 100 struct MinHeapNode { char data; unsigned freq; struct MinHeapNode *left, *right; }; struct MinHeap { unsigned size; unsigned capacity; struct MinHeapNode** array; }; struct MinHeapNode* newNode(char data, unsigned freq) { struct MinHeapNode* temp = (struct MinHeapNode*)malloc (sizeof(struct MinHeapNode)); temp->left = temp->right = NULL; temp->data = data; temp->freq = freq; return temp; } struct MinHeap* createMinHeap(unsigned capacity) { struct MinHeap* minHeap = (struct MinHeap*)malloc(sizeof(struct MinHeap)); minHeap->size = 0; minHeap->capacity = capacity; minHeap->array = (struct MinHeapNode**)malloc(minHeap-> capacity * sizeof(struct MinHeapNode*)); return minHeap; } void swapMinHeapNode(struct MinHeapNode** a, struct MinHeapNode** b) { struct MinHeapNode* t = *a; *a = *b;…arrow_forwardpalindromes Write a function palindromes that accepts a sentence as an argument. The function then returns a list of all words in the sentence that are palindromes, that is they are the same forwards and backwards. Guidelines: • punctuation characters .,;!? should be ignored • the palindrome check should not depend on case Sample usage: >>> palindromes ("Hey Anna, would you prefer to ride in a kayak or a racecar?") ['Anna', 'a', 'kayak', 'a', 'racecar'] >>> palindromes ("Able was I ere I saw Elba.") ['I', 'ere', 'I'] >>> palindromes ("Otto, go see Tacocat at the Civic Center, their guitar solos are Wow!") ['Otto', 'Tacocat', 'Civic', 'solos', 'wow'] >>> palindromes ("Otto, go see Tacocat at the Civic Center, their guitar solos are wow!")==['Otto', 'Tacocat', 'Civic', 'solos', 'wow'] Truearrow_forwardUse C++ programing language Write a modular program that analyzes a year’s worth of rainfall data. In addition to main, the program should have a getData function that accepts the total rainfall for each of 12 months from the user and stores it in an array holding double numbers. It should also have four value-returning functions that compute and return to main the totalRainfall, averageRainfall, driestMonth, and wettestMonth. These last two functions return the number of the month with the lowest and highest rainfall amounts, not the amount of rain that fell those months. Notice that this month number can be used to obtain the amount of rain that fell those months. This information should be used either by main or by a displayReport function called by main to print a summary rainfall report similar to the following: 2019 Rain Report for Springdale County Total rainfall: 23.19 inches Average monthly rainfall: 1.93 inchesarrow_forward
- Declare a student structure that contains : Student's first and last nameStudent IDCreate the following functions: getStudentInfo(void) Declares a single student, uses printf()/scanf() to get inputReturns the single student backprintStudentInfo(student_t *st_ptr) Takes the pointer to a student (to avoid making a copy)Prints out all of the student informationDeclare an array of five studentsUsing a for loop and getStudentInfo() function, get input of all the studentsUsing a for loop and printStudentInfo() function, print all the output of all students.arrow_forwardCheck 1 ALLLEURE #include #include using namespace std; void PrintSize(vector numsList) { cout intList (2); PrintSize(intList); cin >> currval; while (currVal >= 0) { } Type the program's output intList.push_back(currval); cin >> currval; PrintSize(intList); intList.clear(); PrintSize(intList); return 0; CS Scanned with Calin canner Janviantars Input 12345-1 Output Feedback? 口口。arrow_forwardrite a function that scans a character array for the character -(hyphen) and replaces it with _(underscore). The program is to be written in 'C' languagearrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT