Content deleted Content added
m →External links: clean up; http->https (see this RfC) using AWB |
Modified and reformatted the algorithm as it was incorrect. |
||
Line 24:
'''NYT(Not Yet Transferred)''' is special node and used to represents symbols which are ''<nowiki/>'not yet transferred'''.
[[File:Leaf step one.png|thumb|Slide_And_Increment(leaf node) sliding starts. P is a leaf node.]]
[[File:Leaf step
[[File:Leaf step three.png|thumb|Slide_And_Increment(leaf node) sliding step 3. Here we increase the current weight by 1.]]
[[File:Leaf step four.png|thumb|Slide_And_Increment(leaf node) sliding step 4. Method comes to an end. P is the new parent.]]
[[File:Internal one.png|thumb|Slide_And_Increment(internal node) sliding starts. P is an internal node.]]
[[File:Internal two.png|thumb|Slide_And_Increment(internal node) sliding step 2. Node P slides in front of next block of nodes, with weight wt+1.]]
[[File:Internal three.png|thumb|Slide_And_Increment(internal node) sliding step 3. Now we increase the weight by 9. Thus the '''''invariant is maintained''''' as the current node is an internal node and should occur in front of leaf nodes of equal weight as we have increased the weight. ]]
[[File:Internal four.png|thumb|Slide_And_Increment(internal node) sliding step 4. Now the 'P' points to the former parent ( as in the case of internal node according to algorithm)]]
leaf_to_increment = NULL
P = pointer to the leaf node containing to the next symbol
IF (P is NYT) THEN
Extend P by adding two children
Left child becomes new NYT and right child is the new symbol leaf node
P = parent of new symbol leaf node
leaf_to_increment = Right Child of P
ELSE
Swap P with leader of its block
IF (new P is sibling to NYT) THEN
leaf_to_increment = P
P = parent of p
WHILE (P != NULL)
Slide_And_Increment(P)
IF (leaf_to_increment != NULL)
Slide_And_Increment(leaf_to_increment)
==== PROCEDURE Slide_And_Increment(P) ====
previous_p = parent of p
wt = weight of p
IF (p is an internal node)
Slide P in the tree higher than the leaf nodes of weight wt + 1
wt += 1
p = previous_p
ELSE
Slide P in the tree higher than the internal nodes of weight wt
wt += 1
Encoder and decoder start with only the root node, which has the maximum number. In the beginning it is our initial NYT node.
Line 129 ⟶ 71:
====Example====
[[File:Adaptive Huffman Vitter.jpg|800px]]
Encoding "abb" gives 01100001 001100010 11.
|