Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Problem 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:

1. 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}

Please don't use hashmap and no library string token function.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M93091353

Have any Question?


Related Questions in Computer Engineering

In the sans examples of policy the database access policy

In the SANS examples of policy, the database access policy states Database user names and passwords may be stored in a file separate from the executing body of the program's code. This file must not be world readable or ...

Let a and b be events the symmetric difference atriangleb

Let A and B be events. The symmetric difference A(triangle)B is defined to be the set of all elements that are in A or B but not both. In logic and engineering, this even is also called the XOR (exclusive or) of A and B. ...

How do you calculate the number of peaks and mass when

How do you calculate the number of peaks and mass when Bromine with two isotopes and phosphate with one isotope are put through a mass spectrometer? The formula is PBr3

Why is formative evaluation importantprovide at least three

Why is formative evaluation important? Provide at least three reasons for using it. What is the difference between formative and summative evaluation? Provide any two types formative evaluation and two types of summative ...

A bar wants to move into a new area they want to find out

A bar wants to move into a new area. They want to find out the average income of people in the area to set a price point. To estimate the income of the locals with an error of at most $5,000 at a 80% confidence level, wh ...

The average cell phone bill is 78 with a standard deviation

The average cell phone bill is 78 with a standard deviation of 10. What is the minimum percentage of cell phone bills that will be between 54 and 102?

Discuss why a financial services organization would benefit

Discuss why a financial services organization would benefit from using one framework over another (COSO, COBIT,) -- choose a framework or frameworks that in your opinion would be most ideally suited for such an organizat ...

Identify at least two 2 factors that have led to the

Identify at least two (2) factors that have led to the explosive growth of digital crime over the past a few decades. Next, describe the most common forms of digital crime, and give your opinion as to why those forms you ...

1 what would be the purpose for a user to protect a

1. What would be the purpose for a user to protect a file from "read" or "write" access by other users? 2. Is there a reason why it would be safer for administrators to use two different accounts when working with a comp ...

Question suppose a new standard the iddd-643 standard is

Question Suppose a new standard, the IDDD-643 standard, is developed for storing numbers in a string of 16 bits. The first bit is used for the sign of the number (0 if positive and 1 if negative). The next 5 bits store t ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As