Difference between revisions of "CSC231 Final Exam Solutoins 2012"
Line 69: | Line 69: | ||
ratio = 1610 to 817 = 50.745342% | ratio = 1610 to 817 = 50.745342% | ||
− | For the bound on the compression ratio. i.e. the best possible compression, that would be 255 identical emoticons. Let's see what that would give if the emoticons are n character long, excluding ''('' and '')'': | + | For the bound on the compression ratio. i.e. the best possible compression, see what happens with a string of 1 icon: (*), compressed as 1 1 *, or 3 bytes. So there's no compression since we go from a 3-byte icon to 3 bytes of compressed storage. Note that this is also true of icons of the form (xx), since they'd get compressed to 1 2 xx which is also 4 bytes. |
+ | For a string of 2 icons, we get (*)(*), which compresses to 2 1 *, so 4 uncompressed bytes to 3 compressed bytes. A little better. So the more repeated icons we have, the better the ratio. The most repetition we can compress is 255 icons, since that's the largest positive unsigned number we can store in a byte. | ||
+ | |||
+ | So the best compressed ratio would be 255 identical emoticons. Let's see what that would give if the emoticons are n character long, excluding ''('' and '')'': | ||
* 255 times (''n''+2) characters, as in (xxx): 255 * (''n''+2) | * 255 times (''n''+2) characters, as in (xxx): 255 * (''n''+2) |
Revision as of 15:24, 20 December 2012
--D. Thiebaut 14:37, 20 December 2012 (EST)