santensuru / adaptive-huffman Goto Github PK
View Code? Open in Web Editor NEWAdaptive Huffman implement using c++
Adaptive Huffman implement using c++
void delete_tree(node **tree) {
if ((*tree)->left != NULL) {
delete_tree(&(*tree)->left);
}
if ((*tree)->right != NULL) {
delete_tree(&(*tree)->right);
}
// At this point, (*tree)->left = NULL && (*tree)->right == NULL. Right?
if ((*tree) != NULL) {
if ((*tree)->parent != NULL && (*tree)->left == NULL) {
(*tree)->parent->left = NULL;
free(*tree);
}
else if ((*tree)->parent != NULL && (*tree)->right == NULL) {
// no chance enter here
(*tree)->parent->right = NULL;
free(*tree);
}
else if ((*tree)->right == NULL && (*tree)->left == NULL) {
free(*tree);
(*tree) = NULL;
}
}
return;
}
I think that (*tree)->parent->right = NULL;
has no chance to execute.
I wonder if you can explain it to me. Thank you!
Why is the extension of encoded file .ah?
Hello, i have an issue compiling the program.
When a write "gcc vitter.cpp input.txt" in the widows terminal, it doesn't work and it says.
"warning: input.txt: linker input file unused because linking not done"
Can you please help me ?
diff --git a/vitter.cpp b/vitter.cpp
index e14f700..1bcab25 100644
--- a/vitter.cpp
+++ b/vitter.cpp
@@ -355,7 +355,7 @@ namespace vitter {
*/
void get_the_code(node **tree, unsigned char symbol, char *do_code, std::queue<char> *code_write) {
char temp[strlen(do_code)+1];
char temp[strlen(do_code)+2];
if ((*tree)->symbol == symbol && (*tree)->left == NULL && (*tree)->right == NULL && (*tree)->weight != 0) {
for (int i=0; i<strlen(do_code); i++) {
(*code_write).push(do_code[i]);
@@ -378,7 +378,7 @@ namespace vitter {
}
void get_nyt_code(node **tree, char *do_code, std::queue<char> *code_write) {
char temp[strlen(do_code)+1];
char temp[strlen(do_code)+2];
if ((*tree)->weight == 0 && (*tree)->left == NULL && (*tree)->right == NULL) {
for (int i=0; i<strlen(do_code); i++) {
(*code_write).push(do_code[i]);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.