Frequency

CPSC2620—Fall 2015

Assignment 4Due: November 6, 2015 11:55 pm

1. Write a program freq.cc which reads in a list of words and produce two lists of output.

• The first list is the list of distinct words in the file as well as the number of timeseach 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 anduse transform in STL). This list should be sorted in “dictionary order” based onthe 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 1computer 2games 1science 1

• The second list is the list of distinct words sorted in decreasing frequency. Wordswith the same frequency should be listed in “dictionary order.” For the list above,the output should look like:Frequency Word——— ———————2 computer1 abcd1 games1 science

You may assume that the words are separated by white

Leave a Reply

Your email address will not be published. Required fields are marked *