Click here to Skip to main content
15,915,770 members
Home / Discussions / Algorithms
   

Algorithms

 
AnswerRe: Two become one... Pin
Chris Maunder10-Dec-06 9:55
cofounderChris Maunder10-Dec-06 9:55 
GeneralRe: Two become one... Pin
Kevnar10-Dec-06 10:13
Kevnar10-Dec-06 10:13 
GeneralRe: Two become one... Pin
Chris Maunder10-Dec-06 10:52
cofounderChris Maunder10-Dec-06 10:52 
GeneralRe: Two become one... Pin
Kevnar10-Dec-06 17:06
Kevnar10-Dec-06 17:06 
AnswerRe: Two become one... Pin
PIEBALDconsult24-Jan-07 4:11
mvePIEBALDconsult24-Jan-07 4:11 
AnswerRe: Two become one... Pin
Rilhas30-Jan-07 13:32
Rilhas30-Jan-07 13:32 
GeneralRe: Two become one... Pin
Kevnar30-Jan-07 14:39
Kevnar30-Jan-07 14:39 
GeneralRe: Two become one... Pin
Rilhas31-Jan-07 14:26
Rilhas31-Jan-07 14:26 
He he he... well.. to be honest... I'm with the naysayers. It is a powerful argument that it cannot be done, and I am one to think that the argument cannot be defeated.

I thought about the more general formula and for you to be able to acomplish fitting 2 numbers A and B into an 8-bit value then it is necessary that max(A)*(max(B)+1)<=255 (the most accurate version needs more elements). You can achieve that with any pair of integer values for A and B that satisfy the condition, not necessarilly below 19. You could have A in the range [0;127] and B in the range [0;1], for example. That would work, because max(A)=127 and max(B)=1, so max(A)*(max(B)+1)=127*(1+1)=254. Or A in [0;50] and B in [0;4].

The closest thing to a work-around I can think of is this trick. But it is a trick. This is because I'm adding the additional information (assumption) that A and B are limited. An 8-bit value can store a given amount of information (lets call that amount 256). Whatever you do with the numbers cannot exceed a global mount of information greater than 256 otherwise it will not be reversible. The trick I presented is that the 2 numbers A and B, together, do not posess more information than 256, so they can fit in an 8-bit value reversibely. The external information required is the limits of the 2 numbers, which, of course, will be visible in the code (the operands for the / and % operations).

The fact that the sum of the bits necessary to represent A and B exceeds 8 is not relevant. For example, I need 5 bits to represent the number 17, but a lot of combinations of those 5 bits are not being used. So, I can use that "extra storage space" to accomodate part of another number. But the numbers should not "overlap", and that is why I should use only the combinations of 5 bits that I din't use before (like 18, 19, 20, ..., and 31) for the other number. This is why I have added the condition where their multiplication is below 256.

Other work-arounds will also need external knowledge. For example, if you know that the 2 numbers A and B are always double of the previous 2 numbers a and b, then, of course, you need 2 bytes for a and b and zero bytes for A and B. So, you successfully compressed 4 bytes to 2 bytes reversibely, since when you receive the 2 a and b bytes you automatically decode A and B without any more bytes.

This external knowledge is the basis of turbo coding, and can be, in fact used, to add extra information to the transmitted bits. This information is not much though, so turbo coding is maily used for error correction (where you lose only a few bits and so the little external knowledge that can be provided can help recover the values that those lost bits should have).

Other forms of external knowledge exist. For example, windows executables always start with the characters M and Z. These 2 characters can be easilly compressed if your application is compressing windows executables. And if the executable was built for INTEL processors than you can compress many of the bytes by knowing which instructions are valid on INTEL processors (and assume the executable will not contain invalid instructions, which is normal). If built for other processors the same reasoning applies. So, as you can see, many forms of external knowledge can be used, but if the external knowledge must be transmitted (telling the decoder that it is dealing with INTEL Windows executables, or MOTOROLA Macintosh executables) then you usually loose more than you gain.

So, in general, given 2 numbers A and B each with any random value between 0 and 255, you cannot join them with whatever operation into a single 8-bit value and later recover them back individually. This is a pretty well know fact in the theory of information (there are mathematical tools and thechniques to analyze how much information somthing really has).

You can mess with the "random" (thus introducing som external knowledge) to try and make things possible (like I did limiting the range for A and B), but there is nothing you can do to the "operation" if you do not change the "random". And there is not a lot of room for creation. You will have to alter the "random" factor to achieve anything new, and at this level (of external information) you are completely free to try out new stuff.

Anyway, I now see this message is getting quite long. I sugest you take a look at http://en.wikipedia.org/wiki/Information_theory[^] for a simple introduction to information theory.

Rogério Rilhas
GeneralRe: Two become one... Pin
Kevnar31-Jan-07 18:17
Kevnar31-Jan-07 18:17 
QuestionGENETIC ALGORITHM FOR BUS ROUTE NETWORK DESIGN, help me Pin
DHIRAJ SHETI7-Dec-06 17:57
DHIRAJ SHETI7-Dec-06 17:57 
AnswerRe: GENETIC ALGORITHM FOR BUS ROUTE NETWORK DESIGN, help me Pin
karam chandrabose8-Dec-06 5:35
karam chandrabose8-Dec-06 5:35 
GeneralRe: GENETIC ALGORITHM FOR BUS ROUTE NETWORK DESIGN, help me Pin
dead_link8-Dec-06 8:37
dead_link8-Dec-06 8:37 
GeneralRe: GENETIC ALGORITHM FOR BUS ROUTE NETWORK DESIGN, help me Pin
Dan Neely8-Dec-06 9:16
Dan Neely8-Dec-06 9:16 
GeneralRe: GENETIC ALGORITHM FOR BUS ROUTE NETWORK DESIGN, help me Pin
DHIRAJ SHETI8-Dec-06 19:14
DHIRAJ SHETI8-Dec-06 19:14 
GeneralRe: GENETIC ALGORITHM FOR BUS ROUTE NETWORK DESIGN, help me Pin
DHIRAJ SHETI8-Dec-06 19:10
DHIRAJ SHETI8-Dec-06 19:10 
Questionfirst occurence of multiple search terms in a string Pin
peterchen5-Dec-06 16:55
peterchen5-Dec-06 16:55 
AnswerRe: first occurence of multiple search terms in a string Pin
Frank Kerrigan5-Dec-06 23:30
Frank Kerrigan5-Dec-06 23:30 
GeneralRe: first occurence of multiple search terms in a string Pin
peterchen6-Dec-06 1:21
peterchen6-Dec-06 1:21 
AnswerRe: first occurence of multiple search terms in a string Pin
Bassam Abdul-Baki6-Dec-06 8:27
professionalBassam Abdul-Baki6-Dec-06 8:27 
AnswerRe: first occurence of multiple search terms in a string Pin
szukuro7-Dec-06 1:02
szukuro7-Dec-06 1:02 
AnswerRe: first occurence of multiple search terms in a string Pin
ricecake7-Dec-06 3:22
ricecake7-Dec-06 3:22 
AnswerRe: first occurence of multiple search terms in a string Pin
A.A.7-Dec-06 3:28
A.A.7-Dec-06 3:28 
GeneralRe: first occurence of multiple search terms in a string Pin
peterchen9-Dec-06 3:05
peterchen9-Dec-06 3:05 
AnswerRe: first occurence of multiple search terms in a string Pin
Harald Krause11-Dec-06 4:33
Harald Krause11-Dec-06 4:33 
Questionfingerprint recognition algorithm Pin
Alex19823-Dec-06 20:41
Alex19823-Dec-06 20:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.