-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNgramTree.h
More file actions
53 lines (39 loc) · 1.06 KB
/
NgramTree.h
File metadata and controls
53 lines (39 loc) · 1.06 KB
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
47
48
49
50
51
52
53
#include <string.h>
struct NgramNode
{
string data;
int count;
NgramNode *left;
NgramNode *right;
NgramNode()
{
count = 0;
}
};
class NgramTree
{
public:
NgramTree();
~NgramTree();
void addNgram(string ngram);
int getTotalNgramCount();
void traverseNgramCounts(NgramNode *node, int& count);
void printNgramFrequencies();
void traverseFrequencies(NgramNode *node);
bool isComplete();
void generateTree(string fileName, int n);
static int compareStr(string str1, string str2);
NgramNode* getNewNode(string data);
void print(NgramNode* root, int indent);
NgramNode* getRoot();
void insert(string data);
NgramNode* insertRecursion(NgramNode* node, string data);
NgramNode* search(string data);
NgramNode* searchRecursion(NgramNode* node, string data);
void removeIterative(string data);
NgramNode* removeRecursion(NgramNode* node, string data);
NgramNode* findMax(NgramNode* root);
NgramNode* findMin(NgramNode* root);
private:
NgramNode *root;
};