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* huffmanCoding(Iter x, Iter y);

// this function print to os huffman tree represented by the root. void print(std::ostream& os, node* root);

// this function release the entire memory used by tree root void releaseMemory(node* root);

//--------------------------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 struct node { explicit node(const T& t = T(), node* l = nullptr, node* r = nullptr) : value(t), left(l), right(r) { }

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

1 Expert Approved Answer
Step: 1 Unlock

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

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!