Settings

Theme

An Elegant Pairing Function [pdf]

szudzik.com

3 points by codeismightier 11 years ago · 3 comments

Reader

sorokod 11 years ago

|R x R| = |R| so the existence of such functions is guaranteed but it is nice to see that some are just a method call away. Does anyone know what pairing function on non negative integers is the most efficient in the number of bits it requires ?

  • Someone 11 years ago

    This PDF only handles mapping N x N to N and vice versa, though.

    For R x R, I would mix the bits of the two numbers

      [a0 a1 a2 a3...]
      [b0 b1 b2 b3...]
    
    to

      [a0 b0 a1 b1 a2 b2 a3 b3...]
    
    I am not sure that is a computable function for infinite-length bit sequences, though. Maybe none of those mapping functions are?
    • sorokod 11 years ago

      Ah yes, I was thinking |N x N| = |N|. So is there a pairing function f: NxN -> N which can be used as compression?

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection