DEV Community

Discussion on: String Compression. Facebook interview question.

Collapse
 
elmuerte profile image
Michiel Hendriks

For plain text a Lempel-Ziv (LZ) approach is better than a Run Length Encoding (RLE).

In normal text you rarely have concecutive characters, but really often repeating segments. This is where LZ shines.

RLE is easier and cheaper to implement, as you don't need to keep a dictionary around. So less memory needed.

Collapse
 
akhilpokle profile image
Akhil

True that ! this question is meant for testing string manipulation skills and not to test compression algorithm skills.

I shall look into LZ approach though ! thanks for the info!