Question: Can someone help me with these functions in C++ Our encoding Let's look at one piece of our encoding: Every encoding uses three characters. The
Can someone help me with these functions in C++




Our encoding Let's look at one piece of our encoding: Every encoding uses three characters. The first is a marker character to indicate that what follows was encoded. The second is a count of how many characters there are (more on that in a moment), and the third is the character that is repeated. So how does the character 'c' represent 6 (the number of a's being encoded). Well, we could use decimal integers (something like :6a) but as soon as there are more than 9 characters in a sequence the encoding requires an extra character (something like :22a for a sequence of 22 a's). We are trying to be as conservative as possible to get the best compression, so we develop a scheme to represent decimal values as individual characters. Here is what we will use: character above, integer value below: 4567 89 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 A BCDEFGH IJKLMNOPQR STUVWXY 2 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 First, why start at 4? Since an encoding uses three characters, there is no point in encoding any sequence that is 3 characters or less. Thus we pass those characters through without encoding. Since the first count we would encode is 4 characters, we use 'a' to represent a count of 4. Second, why stop at 55/capital Z. We could indeed go further and use all kinds of weird characters (like, S, *, etc.) to represent a count which would get us into the 100's, but we thought 4-55 is a good enough range for this project
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
