Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Write a C++ program freq.cc which reads in a list of words and produce two lists of output. You may assume that the words

1. Write a C++ program freq.cc which reads in a list of words and produce two lists of output. You may assume that the words are separated by white space. The list is terminated by end-of-file.

  • The first list (use map) is the list of distinct words in the file as well as the number of times each word occurs in the input. The words should first be converted to lower case (write a helper function to convert a character to its lower case equivalent and use transform in STL). This list should be sorted in dictionary order based on the words. If the list of words is:

     abcd Computer science computer games 

    The output should look like (the exact format is up to you):

     Word Frequency --------------------- --------- abcd 1 computer 2 games 1 science 1 
  • The second list (use vector pairs) is the list of distinct words sorted in decreasing frequency. Words with the same frequency should be listed in dictionary order. For the list above, the output should look like:

     Frequency Word --------- --------------------- 
     2 computer 1 abcd 1 games 1 science 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions