TIP: prefer to use containers and algorithms from the standard library rather than hand-coded data structures and algorithms. Learn what is in the standard library and how to use it.
In 2574 you saw how to implement data structures and common algorithms for sorting and searching. However, the C++ standard library provides implementations of these that are efficient and well tested, so you should prefer to use them over hand-coded approaches whenever feasible.
Aside: This might cause you some annoyance, why did we ask you to write code in 2574 that already exists? The reasons are that: one, it helped you understand which data structure and algorithm to use and under what tradeoffs, two, it was good experience, and three, in some cases, often in embedded programming, the C++ standard library is not a viable option.
This extends beyond complex algorithms, to what might appear as simple loops.
Links:
The goal of this exercise is to learn how to look for useful parts of the standard library and how to use it generally.
GitHub Invitation URL: exercise5
Prerequisites:
Exercise 01: Setup
and have a working compiler.Steps:
Clone the assignment for today after accepting the GitHub invitation at the link above.
git clone https://github.com/VTECE3574/exercise05-USER.git
where USER is your GitHub username. You will have to enter your GitHub username and password.
In a file named wordcount.cpp write a program that reads all the words from a text file name "prose.txt", counting how many times each word appears, sorting them from the most frequently appearing to least, then writing to standard out the top 10 most frequently used words.
Finally, use git push to synchronize the repository with that on GitHub
You have completed the Exercise.