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 (8th Edition)
Additional Engineering Textbook Solutions
Starting Out with C++: Early Objects
Web Development and Design Foundations with HTML5 (8th Edition)
Programming in C
Modern Database Management
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Starting Out with Java: From Control Structures through Objects (6th Edition)
- 7- ______ is the alternate of sizeof(); function. a. strtolower(); b. strtoupper(); c. isset(); d. count();arrow_forwardC++ 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 programming language Question (Strings) Write a function find_Substring() that finds a substring into a string. Pass array s1 and s2 to this function and prints if the substring is present or not. Expected Output 1: Enter string This is a javascript Enter substring script The substring is present Expected Output 2: Enter string This is a javascript Enter substring Jscript The substring is not presentarrow_forward
- Programming Language: Python Limitations: Not allowed to use sklearn libraryarrow_forwardC++ code NB: Pointers must be usedarrow_forwardC programming In this task you are required implement a function that counts the number of alphabetical characters in a string. The function declaration is int count_isalpha(const char *str);. argument str is a constant string that will be processed to find the number of alphabetical characters. It returns the number alphabetical characters before the termination characterarrow_forward
- Function 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_forwardHelp now please Pythonarrow_forwardHuffman 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_forward
- palindromes 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_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_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