Declare a struct tokenfreq that consists of two data members

Assignment Help Computer Engineering
Reference no: EM132103938

Problem 1:

1. Given a string variable string s; initialize the value of s by receiving a paragraph in English text from the standard input cin. You could assume that this paragraph consists of no more than 100 tokens.

Again, tokens are sequences of contiguous characters separated by any of the user-specified delimiters (e.g., white spaces and Comma).

Please implement a C++ program to recognize each unique token in s and its frequency (i.e., the number of times this token appears in s); Specifically, you are required to include the following elements in your program:

Identify the least frequent letter in the above text. Implement a separate function void getLeastFreqLetter() for this task. The main() function then calls this function to find out the least frequent letter and its frequency.

2. Declare a struct TokenFreq that consists of two data members: (1) string token; and (2) int freq; Obviously, an object of this struct will be used to store a specific token and its frequency. Remember to declare this struct at the beginning of your program and outside any function. A good place would be right after the "using namespace std;" line. This way, your functions will be able to use this struct to declare variables.

3. Implement the function vector getTokenFreq( string& s); Given the input string s, this function identifies all the unique tokens in s and the frequency of each token. It stores all the identified (token, freq) pairs in a vector and returns this vector to the calling function. In this homework, these tokens are case sensitive. For example, "Hello" and "hello" are considered to be two different tokens.

Problem 2:

Implement another C++ program to sort a list of integers using the selection sort algorithm. You are required to use an integer vector to store the input numbers typed from the keyboard. The declaration of this vector will be in main().

You'll need to implement a separate function readData() to read numbers from the keyboard; implement a separate function called selectionSort(), which will be called by the main() function to sort the afore-mentioned vector; implement another function printVector() to print out the content of the vector. This function will be called by main() right after calling readData()and selectionSort(), respectively, to print out the vector content before and after being sorted.

Assume that you type the following input string on your keyboard and store it in string s: ?"And no, I'm not a walking C++ dictionary.

I do not keep every technical detail in my head at all times. If I did that, I would be a much poorer programmer. I do keep the main points straight in my head most of the time, and I do know where to find the details when I need them. by Bjarne Stroustrup" After having called the getTokenFreq() function, you should identify the following list of (token, freq) pairs and store them in a vector (note that the order might be different from yours): { 'no,': 1, 'and': 1, 'walking': 1, 'be': 1, 'dictionary.': 1, 'Bjarne': 1, 'all': 1, 'need': 1, 'Stroustrup': 1, 'at': 1, 'times.': 1, 'in': 2, 'programmer.': 1, 'where': 1, 'find': 1, 'that,': 1, 'would': 1, 'when': 1, 'detail': 1, 'time,': 1, 'to': 1, 'much': 1, 'details': 1, 'main': 1, 'do': 3, 'head': 2, 'I': 6, 'C++': 1, 'poorer': 1, 'most': 1, 'every': 1, 'a': 2, 'not': 2, "I'm": 1, 'by': 1, 'And': 1, 'did': 1, 'of': 1, 'straight': 1, 'know': 1, 'keep': 2, 'technical': 1, 'points': 1, 'them.': 1, 'the': 3, 'my': 2, 'If': 1}

Reference no: EM132103938

Questions Cloud

What is the set of all possible values for the check digit y : What is the set of all possible values for the check digit Y? For more details about the zones defined in the US, you may refer to your lectures.
Create an accordion control for a faq page about rummage : Create an accordion control for a FAQ page about rummage sales. Each content area should provide information about rummage sales, and garage sales.
What volume of no2 will be produced : If we combine 3L of NO and 1.5L of O2, and they react according to the balanced equation 2NO(g)+O2(g)
Calculate the amount of heat : Calculate the amount of heat (q) liberated (or adsorbed) in a yeast brew upon fermentation of 100 g of glucose
Declare a struct tokenfreq that consists of two data members : You are required to use an integer vector to store the input numbers typed from the keyboard. The declaration of this vector will be in main().
New reduced heat liberation process : Show the calculations of heat (q) in support of your suggestion for a new monosaccharide to use in this new reduced heat liberation process.
What is a strong acid : What is a Strong acid? how is a strong acid is different than a concentrated acid?
How do svante arrhenius : How do Svante Arrhenius, Johannes Nicolaus Brønsted and Thomas Martin, and G.N. Lewis each define acids and bases?
Write a program that searches the array of up to 21 values : Write a program that searches the array of up to 21 data values, in the range of 10 - 70 using a linear search. The array is filled with random numbers.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Recommendation on the action that the company needs

Prepare a recommendation on the action that the company needs to take against the offender - Prepare a recommendation on the action that the company needs to take against the offender.

  Discuss requirements definition and requirements analysis

Summary of the article including an analysis of the problem and the technique used to solve the problem and

  Is she the right person to start the conversation

If "yes," how should she proceed? Is she the right person to start the conversation? Who should she have the conversation with?

  Describe a scheme that allows for buy and sell orders

Describe a scheme that allows for buy and sell orders to be entered in O(logn) time, independent of whether or not they can be immediately processed.

  What is the flow of control in a while statement

How does a case statement differ from an if statement? What is the flow of control in a while statement? Why is a while statement called a pretest loop?

  How much mathematics is necessary to be a meteorologist

In general, meteorological models are based on the time-dependent equations of what fields? How much mathematics is necessary to be a meteorologist?

  Explain why rinse series of steps is not a good algorithm

Explain why the Rinse series of steps is not a good algorithm, and then rewrite the series so it is. Shampooing.

  Draw gantt chart that shows completion time for each process

Draw a Gantt chart that shows the completion times for each process using first-come, first-served CPU scheduling.

  What are the latest advancements in cabling

Why would a company want a network on its premises? How will a department or company benefit by having a network.

  Write a program that stores fifty random numbers in a file

Write a program that stores 50 random numbers in a file. The random numbers should be positive with the largest value being 1000.

  Write a complete cpp program that reads two whole numbers

Write a complete C++ program that reads two whole numbers into two variables of type int and then outputs both the whole number part and the remainder.

  Calculate the rate of condensation per unit of surface area

In a part of a solar-operated seawater desalting plant, air saturated with water vapor at 1 atm and 55°C passes into a condenser where the fresh water.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd