Problem 185. Data decompression
A chunk of data is to be 'decompressed'.
Input:
- compressed: a row vector of uint8 values. This is the compressed data.
- table: a cell-array of strings. Each string contains only '1's and '0's and represents a binary code.
- alphabet: a string containing all possible symbols that may occur in the decompressed data. The symbol at alphabet(x) is encoded with the code at table{x}.
Output:
- decompressed: a string with the decoded message.
Example:
compressed=[93,85,127] table={'1','010'} alphabet='al' ==> decompressed = 'laaalalalaaaaaaa'
because:
[93,85,127] = '01011101 01010101 01111111' in binary decoded from left to right: '010 1 1 1 010 1 010 1 010 1 1 1 1 1 1 1' = l a a a l a l a l a a a a a a a
Remarks: The message is such that always exactly all bits of compressed are used. The solution is unique (see prefix-free code).
Solution Stats
Problem Comments
-
2 Comments
Tomasz
on 1 Feb 2012
Update: two randomized tests added to the suite.
Nikolaos Nikolaou
on 28 Oct 2020
i donnot understand the uint8 twist :/
Solution Comments
Show commentsProblem Recent Solvers83
Suggested Problems
-
It dseon't mettar waht oedrr the lrettes in a wrod are.
1936 Solvers
-
Find the largest value in the 3D matrix
1553 Solvers
-
300 Solvers
-
Create an index-powered vector
821 Solvers
-
Convert from Fahrenheit to Celsius
25163 Solvers
More from this Author7
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!