3

I need to encode a sequence S of an arbitrary number of elements (but finite) with an whole number K, and be able to decode K in order to obtain back the initial sequence.

I need to do it such that a computer be able to cope good with the number K.

I did it so (in lisp):

  • suppose that the sequence S has n elements e1, ... en

  • generate first n prime numbers p1 ... pn

  • write K = p1^e1 + p2 ^ e2 + ... + pn ^ en

I tried this method. However, I get huge numbers.

I know that it is possible to use the chinese remainder theorem to solve the problem, and the K obtained so is not that large.

Somebody can help me to use this theorem such that I encode a sequence ?

EDIT:

I wish to see the algorithm of encoding using ch r th using a concrete simple example. I cannot understand the theoretical ideas from wikipedia and other web resources.

alinsoar
  • 15,386
  • 4
  • 57
  • 74
  • We're not going to do your work for you. Show us what you've tried so far, and where you're stuck. – Charles Jan 16 '13 at 08:23
  • I do not need to do work. I need somebody to explain me the logic of the algorithm how to encode this, exactly in the same way I explained how I did, using a sequence of prime numbers. In my case, the generated number K is too great, so the method has not practical use. – alinsoar Jan 16 '13 at 08:25
  • I heard that one can use the chinese remainder th. to encode the sequence, and I wish somebody to explain me the idea. This is what I ask. – alinsoar Jan 16 '13 at 08:26

1 Answers1

3

You are looking for Gödel numbering of sequences. This is a way of encoding a (finite) sequence of numbers as a single number. The Chinese Remainder Theorem gives a recursive method of construction.

borrible
  • 17,120
  • 7
  • 53
  • 75
  • Can you describe concretely the algorithm , because I cannot understand the theory from Wikipedia and similar articles ? – alinsoar Jan 17 '13 at 02:29