Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

8. Modied Stash(15 points) In the following exercise you will again use the Stash structure, however with two modi- cations: (a) you will have a

image text in transcribed
8. Modied Stash(15 points) In the following exercise you will again use the Stash structure, however with two modi- cations: (a) you will have a new integer member to store the desired increment to be used during reallocation (not a xed 100 value as in the book) (b) you will have another integer member variable to count the number of re-allocations (calls to the inate method) the Stash structure needed during its use. You will now write a variation of the run-length encoder you wrote in the previous lab using the Stash structure 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, then add the character C, |N| times and then add a newline character ('\ '). If a pair (85,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 inate() 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: Input: 10 a 2 b 3 c 1 85 99 Output: aabbbc 1 10

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

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions