GATE Computer ScienceEasyGATE CS (PYQ pattern)

A routine compresses runs in place: each maximal run of a repeated character c of length L becomes c if L = 1, else c followed by the decimal digits of L. What does it produce for the input "aaabccddddddddddeff"?

  1. A. a3bc2d10ef2
  2. B. a3bc2d10e1f2
  3. C. a3b1c2d10e1f2
  4. D. a3bc2d9ef2

Correct answer: A. a3bc2d10ef2

Runs: aaa -> a3, b -> b, cc -> c2, dddddddddd (10 d's) -> d10, e -> e, ff -> f2. The count 10 is written as two digits.

More Programming and Data Structures (GATE) questions

Exams that ask this topic