Re: Mapping rationals to binary strings while preserving order



On 13 Jul 2006, [iso-8859-1] Torben Ćgidius Mogensen wrote:

So, we can uniquely represent u/v by the first log(v^2) bits of the
binary expansion of u/v. This obviously preserves lexicographical
order and it uses at most 2*log(v) bits, so it is better than neleai's
solution.

Maybe I misunderstand something (I'll try to go through your proof later
today when I have more time), but
1/3 = 0.0101010101...
5/16 = 0.0101000000...
For 5/16, we have 2*log_2(v) = 2*log_2(16) = 2*4 = 8 bits, so we get
0.01010000
and for 1/3, if we use 5 bits or less, we'll get a string that is
lexicographically smaller than the string for 5/16, e.g.:
0.01010
So for v = 3, we must use at least 6 bits, but 2*log_2(3) is less than 6
-- even 2*ceiling(log(3)) is less than that.

If we use more bits, the same problem appears eventually. E.g. if we
represent 1/3 by 0.01010101, the problem occurs for
85/256 = 0.010101010000....0,
where we again have a lexicographically larger string for 85/256 than we
do for 1/3, even though 1/3 is greater than 85/256.

-----
Janez


.



Relevant Pages

  • Re: Mapping rationals to binary strings while preserving order
    ... Janez Brank writes: ... binary expansion of u/v. ... and for 1/3, if we use 5 bits or less, we'll get a string that is ...
    (comp.theory)
  • Re: Wos goin on ere den?
    ... You didn't misunderstand me Jerry. ... string to the same as the displayed one with the ellipses (although it would ... quite got the hang of the byVal behaviour for API functions. ...
    (microsoft.public.vb.general.discussion)
  • RE: Listview tooltips not working properly
    ... string into 2 lines while the string hasn't a space character within it. ... Please correct me if there is any misunderstand. ... This posting is provided "AS IS" with no warranties, ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Downloading a file with JS
    ... Put the content of the text file into a string variable in an external ... > sorry, misunderstand the question ... > does Sandor said she have a file placed in the server, ...
    (microsoft.public.scripting.jscript)
  • Re: String Manipulation Problem
    ... > Ok, but that doesnt explain the method replacein String class, which ... > modifies a string. ... You seem to misunderstand something (JLS 3.10.5 to be precise). ...
    (comp.lang.java.programmer)