Posted January 18, 201114 yr String compression algorithms:1. First simple algorithm:Input string "Acccc";We store first 2 chars "Ac" +a char: - first bit should be set whit 1 for marking that we have a compression here - rest of bits will filled whit numbers of duplicates - under this case 3"Acccc" -> Ac[3]2. Second algorithm:Input string "the Udrea, the Basescu";* We store "the Udrea, " +First char: - first bit should be set whit 1 for marking that we have a compression here - rest of bits will filled whit the lenght of duplicate string - under this caseSecond char: - all bits should contain the position from where to take the string - under this case 11"the Udrea, the Basescu" -> "the Udrea, [11,3] Basescu" Edited January 18, 201114 yr by CodeRipper
January 18, 201114 yr I think most of us already though of the first algo. You can even make it shorter by removing the second bracket. Ac$3 for instance where $ is the indicator. I ran some tests with it and you barely save any space (unless whitespace).
January 21, 201114 yr If you just use one separator you cant have strings like Accccc123 because that makes Ac$5123A + 5123 times cNot really what you intendedAnd yeah, none of these really beat Huffman unless you have something like 5000 of the same character
Create an account or sign in to comment