Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In C++ please and please use the bubble sort algorithm for this problem PLEASE USE THIS SKELETON CODE #include #include #include using namespace std; //
In C++ please and please use the bubble sort algorithm for this problem
PLEASE USE THIS SKELETON CODE
#include
#include
#include
using namespace std;
// MISSING FUNCTION DECLARATIONS HERE (you can remove these comments)
int main()
{
string sentence;
// MISSING (short) CODE HERE TO GET SENTENCE FROM USER (you can remove these comments)
sort_string(sentence, sentence.size());
print_freq(sentence, sentence.size());
return 0;
}
// MISSING FUNCTION DEFINITIONS HERE (you can remove these comments)
sentence.cpp The program will ask the user for a sentence and will then, re-arrange the letters in the sentence by - (a) sorting them in alphabetical order (per ASCII codes) and - (b) removing all non-alphabetical characters. The program will then show the frequency of every letter in the string (but just the alphabetical characters). You have to distinguish between upper and lower-case alphabet characters. For example, see the 2 runs below: $ ./ sentence Enter sentence: How now brown cow? Sorted and cleaned-up sentence: Hbcnnoooorwwww H: 1 b: 1 C: 1 n: 2 0:4 r: 1 W: 4 $ ./ sentence Enter sentence: $1,234.00 Sorted and cleaned-up sentence: Requirements 1. Your program must utilize the Bubble Sort algorithm (not another sorting algorithm) that we reviewed in lecture (and also found in Ch. 7 of your textbook). You will need to adapt the algorithm to a string, rather than to an array of integers. 2. Be sure to utilize only techniques we've covered in lecture. Do not use "special" arrays or pointers, do not use vectors, do not use built-in sorting functions, etc. You will get zero points if you do. 3. Start your program using the sentence.cpp program that I've provided you with. The skeleton program shows 2 called functions, which, of course, you must use. You can create more functions in your program if you need to (you likely will)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