Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why not use Huffman's Coding? #44

Open
swayam18 opened this issue Nov 25, 2013 · 0 comments
Open

Why not use Huffman's Coding? #44

swayam18 opened this issue Nov 25, 2013 · 0 comments

Comments

@swayam18
Copy link

Given the question of mutability and the difficulty of coming up with these questions, should we instead use Hoffman's encoding to produce the bits from yes/no questions?

To the uninitiated, Hoffman's coding allows you to take into account the probability of something being true, giving us a lot of flexibility over the questions!

For example, assume that there are 4 people in the world: 2 red heads, 1 blond and 1 brunette.

The following questions can then uniquely identify each person:
Are you a red head?
Are you blond?

Here is why: The probability breakdown is as follows:

Red Head: 50%
Blonde: 25%
Brunette: 25%

If their answer is yes to the first question, assign a '1' as the first bit and the second bit as 0 for the first redhead and 1 for the second red head (Doesn't matter as long as they are unique)!. The trick here is to ignore the answer to the second question

If no, assign 0 as the first bit and 1 as their second if they are a brunette, and 0 otherwise.

Ultimately, we have:

00: Blonde
01: Brunette
10: Redhead 1
11: Readhead 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant