Question: Implement the following 3 functions in c++. Descriptions below: //---------functions below---------------- #include #include key.hpp template //this function return a pointer to a root node of
Implement the following 3 functions in c++. Descriptions below:
//---------functions below----------------
#include
#include "key.hpp"
template
//this function return a pointer to a root node of the Huffman tree for a sequence of symbols in [x, y).
bnode
// this function print to os huffman tree represented by the root. void print(std::ostream& os, node
// this function release the entire memory used by tree root void releaseMemory(node
//--------------------------end--------------
//-------------key.hpp-------------------//
struct key { explicit key(char av = 0, int ac = 0) : value(av), count(ac) { } char value; int count; };
// compare two skeys inline bool operator<(const key& lhs, const key& rhs) { return ((lhs.count < rhs.count) || (!(rhs.count < lhs.count) && (lhs.value < rhs.value))); }
template
T value;
node* left; node* right; };
//--------------end key.hpp-----------//
test use BUAHAHAHAHAAAAAA
the output should be
B 000 U 001 H 01 A 1
output's order is irrelevant
Step by Step Solution
There are 3 Steps involved in it
To implement the described functions for Huffman Coding in C lets proceed with a structured solution Step 1 Implement huffmanCoding Function This func... View full answer
Get step-by-step solutions from verified subject matter experts
