Some error occured while loading page for you. Please try again.
You are viewing a single comment's thread. Return to all comments →
you don't need to check that both left and right are null. This is a property of Huffman codes.
Your comment is misguiding. We need to either check if a node is leaf by checking for left and right NULL OR we can check whether the char data of node is empty or not.
And what is the property of Huffman code you are referring to.
in a huffman tree, a parent node will always have 2 child as we begin by combining 2 nodes and repeat it untill we are done. due to this property, we can safely say that if either of the left or right pointer is null, the other one is also null, and hence it is a leaf node.