/*binary tree node implementation with just an element field (no keyand pointers to children *class huffnode implements binnode private element/element for this node private huffnode left/pointer to left child private huffnode right/pointer to right child /*constructors *public huffnode({left right nullpublic huffnode( valleft right nullelement valpublic huffnode( valhuffnode lhuffnode rleft lright relement val/*return and set the element value *public element(return elementpublic void setelement( velement /*return and set the left child *public huffnode left(return leftpublic huffnode setleft(huffnode preturn left /*return and set the right child *public huffnode right(return rightpublic huffnode setright(huffnode preturn right /*return true if this is leaf node *public boolean isleaf(return (left =null&(right =null)figure implementation for huffman tree nodes internal nodes and leaf nodes are represented by separate classeseach derived from an abstract base class have selected node in place of node as the child of node howeverthis is impossible because and are the letters with least frequency theorem function buildhuff builds the huffman tree with the minimum external path weight for the given set of letters proofthe proof is by induction on nthe number of letters base casefor the huffman tree must have the minimum external path weight because there are only two possible treeseach with identical weighted path lengths for the two leaves