Clear questions and runnable code
get the best and fastest answer
By inversely proportional, I meant that the number of questions asked to identify an animal (Q) multiplied by how many times the animal is chosen (C) should be constant. If a goat appears a hundred times more often than a unicorn then it should take a hundred times more questions to identify the unicorn than the goat.
In roboticus' example, which you seem to be endorsing, this is the tree produced:
The fish with a frequency of 150 requires 2 questions; the unicorn with a frequency of 1, required 9. And it puts walrus(15), badger(17), seal(18), wolverine(22) & frog(28) at the same level.
So the inverse proportionality is relative rather than mathematically absolute. It would require the insertion of 291 additional questions above the unicorn to achieve the math you describe, and in the process, throws away the "compressive" attribute that defines Huffman.
If non-compressive, relative inverse proportionality is sufficient, then my original reading of your question would be more accurate:
Which brings me back to the idea that what roboticus' use of Huffman does, is minimise the depth of the tree.
But if that were the goal, then its maximum depth of 9 is 3 more than is required:
All of which I guess means, that I have no idea what you set out to achieve :(
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
In reply to Re^5: Challenge: Optimal Animals/Pangolins Strategy