Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ CODE PLEASE In the following exercise you will use the Stash class , but with two modifications: 1) you will have a new integer

C++ CODE PLEASE

In the following exercise you will use the Stash class, but with two modifications:

1) you will have a new integer member to store the desired increment to be used during re-allocation (and not a fixed 100 value as in the book);

2) you will have another integer member variable to count the number of re-allocations (calls to the inflate method) the Stash class needed during its use.

You will now write a variation of the run-length encoder you wrote in the previous lab using the Stash class with each entry being one character. First of all you will read as input an integer that will tell how much the Stash should use as increment. Then you will read a sequence of pairs, each pair containing a character and a number. For each pair (C,N), add to a Stash object the character C, N times without spaces.

If a pair has a negative N number, add the character C, |N| times and then add a newline character (' ').

If a pair (&,99) is read then stop reading values, print the elements in the Stash in the order received, and then print two numbers: the number of calls that were made to inflate() inside your Stash object, and the total size in bytes that was allocated by the Stash object at the end (the value of the quantity variable).

Example 1:

Input: 1 k -1 e 2 r -3 & 99

Output:

k eerrr 8 8 freeing storage

Example 2:

Input: 8 k -1 e 2 r -3 & 99

Output: k eerrr 1 8 freeing storage

Example 3:

Input: 7 k -1 e 2 r -3 & 99

Output: k eerrr 2 14 freeing storage

Example 4: Input: 1 h 1 i 1 & 99

Output: hi 2 2 freeing storage

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

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

More Books

Students also viewed these Databases questions

Question

Explain the need for a critical analytical approach to studying HRM

Answered: 1 week ago

Question

Explain the market segmentation.

Answered: 1 week ago

Question

Mention the bases on which consumer market can be segmented.

Answered: 1 week ago

Question

LO3 Discuss the steps of a typical selection process.

Answered: 1 week ago