How to find the minimal number of bits to encode a set of known strings? [closed] - algorithm

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
How to find the minimal number of bits to encode a set of known strings?

If the set of strings is known to both sender and receiver, then you need zero bits to transmit it. (In effect, the message is "Use the known set." I know that sounds silly, but it is often part of a comms protocol.)
If you need to send a single string from the set, you can send its ordinal index, using log2 N bits, where N is the size of the set.
if you are repeatedly sending messages containing a single string from the set but the frequency distribution of the messages is non-uniform, you can Hoffman-code the ordinal. That will optimize the total size of all messages over time.

I don't know exactly if you require this one but still have a look at it , it might help you . Let me know if it does:
Compression algorithm

Related

Combine sequence of positive integers into one unique integer [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 months ago.
Improve this question
So I've got a list of positive integers and I want to combine all elements into one unique integer. But I am only able to use basic arithmetic (+, -, *, /).
The result should have the semantics of a hash for the input sequence. So no other sequence should be able to produce it.
Any suggestions how I could tackle this problem?
Interpreting "hash" to mean that the output domain is bounded, it's not possible to "hash" an unbounded input sequence to a unique output. Those numbers can only be compressed so much without losing information.
If this were possible, compression ratios for any digital information could approach infinity.

How does Ruby generate random numbers using [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
So when using, for example, rand(10), how does ruby generate the random number? I have very little knowlege about random number generation techniques, so I would like to get to know them better.
Ruby is open-source. I'll demonstrate how to locate the PRNG (pseudo random number generator) code, as there's no way to generate truly random numbers using a deterministic CPU.
Looking at the repository, we see a suspiciously-named file, random.c. Looking inside, it's in C, but that's ok, it has comments. The first function is genrand_real, calling genrand_int32, which takes a struct MT. This function is defined in mt19937.c and looking at that file, it uses bitwise operations to get the next state of the random number generator and applies more bitwise operators to generate the number desired.

How to built algorithm that can generate random set of digits and letters [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
On what language is more easy to code that kind of algorithm and make it more flexible to changes.
It's pretty easy to do, at least in widely used programming languages that I'm aware of (e.g. C++, Java, etc).
Store all possible characters in an ordered collection like array or a string. For example, you can make a string that contains all letters and digits like so:
// Exact syntax depends on your programming language.
//
// I used a string for simplicity here but some languages don't allow
// you to access individual string characters so you'll need an array.
//
string a = "abcdefghijklmnopqrstuvwxyz0123456789";
Generate a random number between 0 and length(a) - 1 (size of your character set array minus one).
Use the number you generated as an index and extract the character from the array at that index.
Congratulations! You've just generated one random character from your character set. Go back to step #2 and repeat N - 1 times (N is here the total number of characters you want to generate).

I am at a crossroads in my program and I was wondering which path would be more efficient time wise [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I currently see two ways to code the next step of my program and there are probably more, but the two routes I have are as follows.
I take the factors of the lowest number and loop through the other numbers two see if they share those common factors.
I find the factors of the lowest number and add it to a list. I then find the factors of the other numbers that do not exceed the lowest and add them to the same list. I then run through the list to check which is the highest number that appears x times.
I am leaning towards 1, but I'm not sure.
Sorry if this is too ambiguous, thanks.
Well, given the ambiguity, as stated: the 1st requires less steps and avoids the allocation of a data structure.

What are the uses/applications of Single precision Floating point numbers? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm doing a project on single precision floating numbers. I was wondering in what fields or areas are these concepts used? Thanks in advance.
For anything requiring larger range than available with integers, and where limited accuracy of number representation isn't important enough to use longer floats. In terms of accuracy, nothing beats integer or fixed point, at the price of their limited range. Say if i wanted cosmological distances in a unit which can be used for both nearer and far objects at the same time, i could think of using those - after all, i'd be mostly interested in the most significant parts of the distance, not in the submillimeter portion.

Resources