Problem : Recall from that it is possible to represent arithmetic, parenthesized expressions using a tree. If a node is an operator, such as a plus or a division sign, each of the children must be either a number, or another expression. In other words, the two children of an operator will be its operands. + 3 4 The above means (3+4). Write a function which will take in a tree_t of the form:
Problem : Assume now that your nodes represent people and their ages and as a result have fields for a person's name and age. Use the following definition for tree_t:
Problem : A Huffman tree is a means of encoding characters, that is, a way of assigning a certain sequence of bits to a character (ASCII is another convention). The idea is that you can save space when storing a file if you can find an encoding for the characters such that the file requires fewer bits overall. We will not cover the process of building such a tree, but we will consider the process of using one. Starting from the root node, you keep walking along either the left or the right branch until you reach the desired character. Moving left corresponds to a 0 bit and moving right to a 1 bit. So, if you have to go left, right, right to get to the character 'A', then the encoding for 'A' is 011. How can you describe the location of all of the nodes that have characters associated with them? The root node, for example, has no character associated with it.The decoding (translation from bits into characters) using a Huffman tree relies on the fact that the encoding of one character is never the prefix of another character. For example, if one character is encoded with the bits '011', then the encodings for all of the other characters cannot start with those same three bits. If there were such a case, then when decoding the bits, it would be ambiguous as to which character was encoded. In terms of the tree this means that there can be no character node which has children; all of the nodes associated with characters must be leaves.