Two characters

Report a typo

If there are only two possible values in your data, compressing it is a lot easier and saves a lot of storage. For example, a stream of binary values, 1111100000001111111001111110011111000000011111110011111100, can be compressed to an array of numbers, N={5,7,7,2,6,2}N = \{5, 7, 7, 2, 6, 2\}, and an array of characters, C={1,0}C =\{1, 0\}. The first character in the array of characters will show that the original data begins with 11, and the array of numbers will indicate the number of repetitions. Because there are only two potential values, if the first item of NN represents five repeats of 11, the second item, 77, will suggest seven repetitions of 00, and so on.

Now suppose Mike has tossed a coin 1515 times and has recorded HH in the case of heads and TT in the case of tails. You have the encoded data of all 1515 tosses in an array of numbers, {5,2,1,4,3}\{5, 2, 1, 4, 3\}, and an array of characters, {T,H}\{T, H\}. Can you write down the decoded data below?

Writing format: HHHTTHHHHTTH

Enter a short text
___

Create a free account to access the full topic