Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Node
- {
- public:
- char symbol;
- int count;
- Node *left = nullptr, *right = nullptr;
- friend bool operator < (const Node &a, const Node &b)
- {
- return a.count < b.count;
- }
- friend bool operator > (const Node &a, const Node &b)
- {
- return a.count > b.count;
- }
- Node(char symbol = '\0', int count = 0, Node* left = nullptr, Node* right = nullptr)
- {
- this->symbol = symbol;
- this->count = count;
- this->left = left;
- this->right = right;
- };
- Node(Symbol s)
- {
- this->symbol = s.a;
- this->count = s.count;
- this->left = nullptr;
- this->right = nullptr;
- };
- Node(Node const& a) : symbol(a.symbol), count(a.count), left(a.left),right(a.right)
- {
- //this->symbol = a.symbol;
- //this->count = a.count;
- //this->left = a.left;
- //this->right = a.right;
- }
- };
- priority_queue<Node,vector<Node>, greater<Node>> tree;
- while (tree.size() > 1)
- {
- Node t1 = tree.top();
- tree.pop();
- Node t2 = tree.top();
- tree.pop();
- tree.push(intersect(t1, t2));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement