MCPcopy Create free account
hub / github.com/algorithm-archivists/algorithm-archive / encode

Function encode

contents/huffman_encoding/code/c/huffman.c:208–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206}
207
208char* encode(const char* input, struct tree** huffman_tree,
209 struct codebook* codebook) {
210 *huffman_tree = generate_tree(input);
211 *codebook = generate_codebook(*huffman_tree);
212
213 char* result = duplicate(get_code(codebook, *input));
214
215 input += 1;
216
217 for (; *input; ++input) {
218 concat(&result, get_code(codebook, *input));
219 }
220
221 return result;
222}
223
224const char* decode_recurse(const char* input, const struct tree* tree,
225 char** result) {

Callers 1

mainFunction · 0.70

Calls 5

generate_codebookFunction · 0.85
duplicateFunction · 0.85
get_codeFunction · 0.85
concatFunction · 0.85
generate_treeFunction · 0.70

Tested by

no test coverage detected