Possible Duplicate:
Text packing algorithm
The setup: I have a bunch of strings which should be put into an (one-dimensional) array, and which are accessed with an offset and a string length.
The problem: Find an algorithm to store those strings as efficiently as possible.
Example: Consider the three strings foo
, foobar
, and array
. The most compact form would be foobarray
: foo
gets accessed with offset 0 and length 3 (0,3) , foobar
with (0,6), and array
with (4,5).
Note that the access of the array with offset and length is mandatory (this is actually the method how the data in the `name' table of an OpenType font is stored).
I'm quite sure that solutions already exist, but I'm probably missing the right keyword to find them in the internet.
Please advise.