{"id":25088890,"url":"https://github.com/massigy/c-huffman-text-compression","last_synced_at":"2026-05-10T06:54:12.388Z","repository":{"id":78992236,"uuid":"568551770","full_name":"MassiGy/C-huffman-text-compression","owner":"MassiGy","description":"This project impelements a basic version of the Huffman text compression algorithm, using the Huffman tree.","archived":false,"fork":false,"pushed_at":"2023-03-11T14:06:46.000Z","size":232,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-07T10:53:29.664Z","etag":null,"topics":["c","compression-algorithm","cprogramming","gcc","git","github","huffman-coding","makefile"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MassiGy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-20T21:47:41.000Z","updated_at":"2023-05-31T21:37:26.000Z","dependencies_parsed_at":"2023-04-14T07:57:53.620Z","dependency_job_id":null,"html_url":"https://github.com/MassiGy/C-huffman-text-compression","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MassiGy%2FC-huffman-text-compression","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MassiGy%2FC-huffman-text-compression/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MassiGy%2FC-huffman-text-compression/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MassiGy%2FC-huffman-text-compression/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MassiGy","download_url":"https://codeload.github.com/MassiGy/C-huffman-text-compression/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246673173,"owners_count":20815521,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","compression-algorithm","cprogramming","gcc","git","github","huffman-coding","makefile"],"created_at":"2025-02-07T10:53:05.193Z","updated_at":"2026-05-10T06:54:07.327Z","avatar_url":"https://github.com/MassiGy.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# C Based Impelementation of Huffman Compression Algorithm.\n\n\n### File Architecture\n\n```BASH\n    .\n    ├── headers\n    │   ├── generic-linked-lists.h\n    │   ├── hcompress.h\n    │   ├── htree-node.h\n    │   ├── main.h\n    │   └── sys_headers.h\n    ├── README.md\n    ├── ressources\n    │   └── init_text.txt\n    └── src\n        ├── generic-linked-lists.c\n        ├── hcompress.c\n        ├── htree-node.c\n        ├── main\n        ├── main.c\n        └── Makefile\n\n\n    3 directories, 13 files\n\n```\n\n### Description\n\n\nThis project implements a basic version of the Huffman compression algorithm for english text only. This is performed as follows:\n\n##### Compression Algorithm\n\n###### Constructing the huffman tree\n- First, go through the text, and for each character create a node storing it and its frequency.\n- Second, append each node to a list.\n- Third, sort the list regarding the frequency.\n- Forth, get the two least, frequency wise, nodes and creat a sub tree, the min will go to the left, and the other one (the max of both) will be the right leaf. \n- Fifth, link these two leaves with a parent node which will have as data the sum of its sons frequencies.\n- Sixth, remove  these two elements from your list.\n- Seventh, insert the sub tree to your list, respecting the order of frequencies.\n- Eighth, redo this for each element of your list.\n- At the end, you will end up with a huffman tree, that you will need to store.\n\n\n###### Subtituting the text with the in-tree binary location\n- First, go to a leaf, while doing that, store the path to it in the appropriate binary form.\n- Once, on the leaf, insert to a new list the leaf character and its binary path.\n- Redo this for each leaf.\n- Then, read the file character by character, for each one, substitute it with its binary path on a binary file.\n- At the end, the binary file will be the compressed file.\n\n\n##### Decompression Algorithm\n\n- First, get back the huffman tree \u0026 the binary file ( the compression result ).\n- Second, walkthough the compressed file bit by bit, using these to traverse the tree.\n- Once, a leaf is hit, write down the character into another txt file. \n- Redo this until END_OF_FILE.\n- Then, the text file will be equal to the initial one.\n\n\n\n    \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmassigy%2Fc-huffman-text-compression","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmassigy%2Fc-huffman-text-compression","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmassigy%2Fc-huffman-text-compression/lists"}