Skip to content

Run-length encoding

words

Level 1 of 3

Also called RLE.

fresh numbers

The test's questions that a run answers, asked again on new numbers whenever you like. The answer, its working and the reason for every other choice come from run-length encoding's own run on the numbers shown.

choose one

question 1

The method runs on bqqqmm. How many characters has it written just after it reads the first m?

123456bqqqmm
the answer, and why

the answer is A

Reading the first q ended b, so 1b. Reading the first m ended qqq, so 3q. 1b3q is 4 characters; mm is written only at the end.

if you chose another

  • That is 1b alone. Reading the first m also writes qqq's run, 3q.
  • That is the whole code, 1b3q2m. The last run is written only at the end.
  • That counts the runs met so far, b, qqq and m. Only runs that have ended are written.

new numbersthe test page's numbers

question 2

How many comparisons does the method make on the text ttttzzz?

1234567ttttzzz
the answer, and why

the answer is D

Each letter after the first is held against the run's letter once. 7 letters, so 6 comparisons.

if you chose another

  • The first letter is compared with nothing. It starts the first run.
  • That counts the runs. Every letter after the first is compared, in a run or not.
  • That counts only the comparisons that find a different letter. Those that find the same count too.

new numbersthe test page's numbers