Start by downloading the assignment files. This zipfile contains a makefile, a test script and inputs/ground truths, and stubs for all of the .cpp files you need. Do not create any additional .h and .cpp files.
Consider the function shown below. Roughly, the function returns true if the letters in the string s are in alphabetical order, false otherwise.
// PRE: s is composed of letters from the English alphabet, with no other characters.
bool isInAlphabeticalOrder(string s) {
int length = s.size();
for (int i = 0; i < length - 1; ++i) {
if (s[i] > s[i+1]) {
return false;
}
}
return true;
}
ASCII is the character encoding we most often use for storing and manipulating text on computers. It assigns a 7-bit code to the common characters used in English writing, including numbers, basic math symbols, and punctuation. Inside memory, we commonly store the 7-bit ASCII code inside the lower bits of an 8-bit byte. Ask a search engine about "ASCII" to find a chart of which codes (numbers) are assigned to which characters.
We will be concerned with how many times the character comparison (s[i] > s[i+1]) is executed. First, implement the isInAlphabeticalOrder function in C++ in the file words.cpp. The makefile contains a definition for words. You can build the executable words for this part of the assignment by running "make words". ("make" or "make all" will build both words and the executable for the second part of the assignment.)
Determine the following for the English words listed in file wordlist (do not convert to lowercase).
You will need to add code to isInAlphabeticalOrder (or create a new function) to help you determine these values.
Note that words.cpp contains code for reading wordlist.
uname@hostname: ~$ ls average_comps.txt average_comps.txt uname@hostname: ~$ gnuplot comps.p uname@hostname: ~$ ls average_comps.png average_comps.png
Please use the provided file mode.cpp, and fill in the function mode. Note: you must write any auxialliary functions you use, and may not include any external libraries to help (other than iostream and fstream). The makefile contains a definition for mode. You can build the executable mode for this part of the assignment by running "make mode".
The zipfile contains a testing script, test.py. You should run this, and other test cases, to verify correctness of your mode function.
You should submit your assignment online to the CourSys submission server. You should submit the following:
The assignment is due at 11:59pm on Monday July 8.