Write a C++ program that outputs a sorted list of words along withtheir frequenc
ID: 3610790 • Letter: W
Question
Write a C++ program that outputs a sorted list of words along withtheir frequencies in the redirectedcin (standard input). The list is sorted in the descending order ofthe word frequency (the word with the
highest frequency is the first in the output). Words with the samefrequency are listed in the
lexicographical (dictionary) order. A word is defined as a maximalstretch of the letters in the English
alphabet and is not case sensitive. The word list maintained by theprogram should always be sorted (in
the lexicographical order) during the process and binary searchshould be used in updating frequency
counts if the word is on the list and finding the future positionin the array if the word is not on the list.
One or two files are made available for you to test yourprogram.
Explanation / Answer
void insertsort(int a[], int n) { int i, j, index; for (i=0; i 0) && (a[j-1] > index)) { a[j] = a[j-1]; j = j - 1; } a[j] = index; } }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.