-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHuffman.h
More file actions
46 lines (35 loc) · 848 Bytes
/
Copy pathHuffman.h
File metadata and controls
46 lines (35 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once
#ifndef Huffman_h
#define Huffman_h
#include<iostream>
#include<queue>
#include<string>
#include<fstream>
using namespace std;
class Huffman
{
struct node {
char data;
int frequency;
node* left, *right;
node(char data, unsigned frequency)
{
left = right = NULL;
this->data = data;
this->frequency = frequency;
}
};
struct compare {
bool operator()(node* left, node* right)
{
return (left->frequency > right->frequency);
}
};
priority_queue<node*, vector<node*>, compare> minHeap;
void printHuffmanCodes(node* root, string str);
public:
void buildHuffmanTree(char characters[], int frequency[], int size);
void printCodes();
void decodeText(string filename);
};
#endif