Jump to content

Talk:Kraft–McMillan inequality

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Proof of existence of a prefix code doesn't seem to make sense to me

[edit]

I'm talking about this:

Conversely, given any ordered sequence of natural numbers,

satisfying the Kraft's inequality, one can construct a prefix code with codeword lengths equal to by pruning subtrees from a full -ary tree of depth . First choose any node from the full tree at depth and remove all of its descendents. This removes fraction of the nodes from the full tree from being considered for the rest of the remaining codewords. Next iteration removes fraction of the full tree for total of . After iterations,

fraction of the full tree nodes are removed from consideration for any remaining codewords. But, by the assumption, this sum is less than 1 for all , thus prefix code with lengths can be constructed for all source symbols.

First, it's wrong that purging a node at depth removes fraction of the nodes from the full tree. It would be true for leaf nodes. But this isn't of much help either. Just knowing that we have of the leaf nodes yet unpurged does not mean that we have a whole full subtree at depth k yet unpurged. Is the above-quoted text actually meant to be a proof?

Hi @Darij:. If I read the history right, you left that unsigned comment on 24 April 2011‎. If you are still interested, note that I've just reworked the proof in question. Hopefully it makes more sense now. Cheers, Gamall Wednesday Ida (talk) 19:49, 28 September 2016 (UTC)[reply]
Hi @Gamall Wednesday Ida:. Thanks for the edits! The proof has grown much in clarity while I was away! (And yes, that was me, back before I had an idea how to sign edits.) I have taken the liberty to edit it even further, hopefully clarifying a few more things. While the proof was morally correct, the way it was written the logic was slightly backwards: the algorithm works not because we don't remove more leaves than we have (removing leaves is never the intent, but always just an effect!), but because we always can find a surviving node at level . The leaves are just the canary that tells us that we can indeed find such a node. (This is purely an issue of writing.) Darij (talk) 06:29, 6 December 2016 (UTC)[reply]
Hello Darij! Thanks for giving this some attention. I agree with the point above. I've taken a very quick look at the current state and am not convinced it's optimal yet. The use of strict inequalities at the end, even if justified for k < n, might end up confusing matters. More crucially, the sentence It clearly suffices to check that up until the last step, there is at least one leaf node remaining (because as long as there is at least one leaf node, there is also at least one node at each level ) seems flatly false to me, and is backwards compared to what you say, correctly, above. Having a leaf left of course does not automatically mean you can fit anything *above* (shorter length) that. I'll look more into it sometime, but can't say when, as I'm rather busy at the moment. — Gamall Wednesday Ida (t · c) 12:39, 6 December 2016 (UTC)[reply]
Still seems wrong to me after a second reading. I'm removed that specific sentence until we can work it out here. I have not touched the remainder of your edit, which looks good to me. — Gamall Wednesday Ida (t · c) 20:28, 6 December 2016 (UTC)[reply]
Excuse me for butting in to your conversation here, but exactly the same issue had puzzled me. I suggest the following modification, and I would be interested to read what you all think about my suggestion, if anything:
EDIT:
Call a full subtree of height whose leaves are a subset of the leaves of the full binary tree of depth , an -triangle.
Identify a codeword of length with a node in the tree at depth , as usual, and also with the -triangle rooted at that node.
Initially, for each there are -triangles.
When we choose a node at depth to represent a codeword of length , then we delete exactly -triangle, and in general, for each with , exactly of the -triangles (namely, those that were contained in that big -triangle).
Therefore, when the time comes to choose a node at depth to represent the th symbol, equivalently, to choose an -triangle, we have already deleted exactly of the original -triangles.
The algorithm is feasible if, and only if, for each , this last sum is strictly less than .
However, , by hypothesis, so everything is ok. Jumpers for goalposts, enduring image (talk) 11:32, 17 November 2022 (UTC)[reply]

Relations among prefix code, uniquely decodable code and Kraft's inequality

[edit]

How about adding something as follows:

Let denotes the lengths of a code satisfy Kraft's inequality; denotes that code is prefix code; denotes that code is uniquely decodable code. Then:

I was confused when I tried to figure out the relations among kraft's inequality, prefix code and uniquely decodable code. This is what I thought about the relations. But I'm not sure whether it's right.

--Li3939108 (talk) 18:20, 24 September 2012 (UTC)[reply]

This version seems more specific and informative and the one above seems redundant.

Let denotes the relation that a code has the lengths ; denotes the lengths of a given set of codewords satisfy Kraft's inequality ; denotes that code is prefix code; denotes that code is uniquely decodable code; Then:

--Li3939108 (talk) 21:23, 24 September 2012 (UTC)[reply]