Implemented the string compression algorithm.