go to start Ex W10
|home |print view |recent changes |changed December 1, 2017 |
exact
|You are 54.196.42.8 <- set your identity!

Sections: Catchup | =[wlist]= AGAIN! | Algorithm / Functor Exercises | wseventh - count words and print out 7th most frequent | woccurrence - cross reference with line numbers | Filling a vector with squares with standard functors |

Catchup ^

wlist AGAIN! ^

You have already implemented the wlist programm twice (once with std::string (Ex4) and once with your word (Ex5)). The implementation using word should be rather short, only a few lines. Until now your wlist output contained the words in ascending order, from a to z. Modify the existing behavior in the following ways and create two new versions of wlist:

Algorithm / Functor Exercises ^

wseventh - count words and print out 7th most frequent ^

Similar to the wfavorite program from last week, only print the 7th most frequent word.

Do not reuse exact code of wfavorite, but again use the most optimal data structure and algorithms for this problem.

woccurrence - cross reference with line numbers ^

Read a text from standard input line by line. While reading count the line numbers. Create a data structure that keeps each word (use your word class) together with all line numbers it occurs upon. Print out a sorted list of words (one word per line), each followed by a list of the line numbers it occurs upon.

Example input:

Hello
Hello again
Song by who?
output:
again 2 
by 3 
Hello 1 2 
Song 3 
who 3 

Filling a vector with squares with standard functors ^

Use standard functors and the std::transform algorithm to fill an std::vector consisting of 10 ones with the 10 squares 1, 4, ..100. Do not use a loop. Do not use std::iota(). Do not use a lambda. Start with the following vector:

    std::vector<unsigned> v(10,1);


|home |print view |recent changes |changed December 1, 2017 |
exact
|You are 54.196.42.8 <- set your identity!

Ex W10
go to start