I am trying to count occurrences of every word in text. So I have stored all words and counts in binary tree:
typedef struct Node{
char* word;
int count;
struct Node *left;
struct Node *right;
struct Node *parent;
} Node;
Now I need to sort tree by number of count. I can't just do while cycle and sort it, so I am wondering, which way I can do it?
Here is example of what I have now:
The - 3
/ \
Project - 1 of - 3
/ \ / \
.... .... .... ....
And I need to print top N words in text.