Data Str & Algorithm HW Solutions 45

Data Str & Algorithm HW Solutions 45 - new

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
45 curr++ // Eat the internal node mark. temp->left = converthelp(inlist, curr); temp->right = converthelp(inlist, curr); return temp; } (c) // Use a helper function with a pass-by-reference // variable to indicate current position in the // node list. template <class Elem> GTNode<Elem>* convert(char* inlist) { int curr = 0; return converthelp(inlist, curr); } // As converthelp processes the node list, curr is // incremented appropriately. template <class Elem> GTNode<Elem>* converthelp(char* inlist, if (inlist[curr] == ’)’) { curr++; return NULL; } GTNode<Elem>* temp =
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: new GTNode&lt;Elem&gt;(inlist[curr++]); if (curr == )) { temp-&gt;insert_first(NULL); return temp; } temp-&gt;insert_first(converthelp(inlist, curr)); while (curr != )) temp-&gt;insert_next(converthelp(inlist, curr)); curr++; return temp; } 6.17 The Huffman tree is a full binary tree. To decode, we do not need to know the weights of nodes, only the letter values stored in the leaf nodes. Thus, we can use a coding much like that of Equation 6.2, storing only a bit mark for internal nodes, and a bit mark and letter value for leaf nodes....
View Full Document

This note was uploaded on 12/27/2011 for the course MAP 2302 taught by Professor Bell,d during the Fall '08 term at UNF.

Ask a homework question - tutors are online