{"id":19036292,"url":"https://github.com/sspeedy99/file-compression","last_synced_at":"2025-07-12T13:08:28.079Z","repository":{"id":100093209,"uuid":"190061188","full_name":"sspeedy99/File-Compression","owner":"sspeedy99","description":"A file compression program written in C++ to compress files using Huffman Coding","archived":false,"fork":false,"pushed_at":"2019-06-11T08:17:52.000Z","size":67,"stargazers_count":24,"open_issues_count":0,"forks_count":8,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-23T19:07:37.767Z","etag":null,"topics":["compression","cpp","data-structures","huffman-compression-algorithm"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sspeedy99.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2019-06-03T18:36:32.000Z","updated_at":"2025-04-08T05:08:59.000Z","dependencies_parsed_at":"2023-04-05T11:04:33.706Z","dependency_job_id":null,"html_url":"https://github.com/sspeedy99/File-Compression","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sspeedy99/File-Compression","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sspeedy99%2FFile-Compression","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sspeedy99%2FFile-Compression/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sspeedy99%2FFile-Compression/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sspeedy99%2FFile-Compression/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sspeedy99","download_url":"https://codeload.github.com/sspeedy99/File-Compression/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sspeedy99%2FFile-Compression/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264995631,"owners_count":23695002,"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":["compression","cpp","data-structures","huffman-compression-algorithm"],"created_at":"2024-11-08T21:53:59.193Z","updated_at":"2025-07-12T13:08:28.074Z","avatar_url":"https://github.com/sspeedy99.png","language":"C++","readme":"**File Compression Using Huffman's Algorithm**\n=========================\n\n\nAbout\n=====\n\nHuffman Algorithm is an efficient way for file Compression and Decompression.\nThis program exactly follows huffman algorithm. It reads frequent characters from input file and replace it with shorter binary codeword.\nThe original file can be produced again without loosing any bit.\n\nUsage\n=====\nCompression:\n```\n\t./encode \u003cfile to compress\u003e\n```\nOutput file named \u003cinputfile\u003e.spd will be produced.\nDecompression:\n```\n\t./decode \u003cfile to uncompress\u003e\n```\n \nFile Structure\n============================\n\n\u003ctable\u003e\n\u003ctr\u003e \u003ctd colspan=\"2\"\u003e  N= total number of unique characters(1 byte)              \u003c/td\u003e \u003c/tr\u003e\n\u003ctr\u003e \u003ctd\u003e Character[1 byte]   \u003c/td\u003e\u003ctd\u003e  Binary codeword String Form[MAX bytes]  \u003c/td\u003e \u003c/tr\u003e\n\u003ctr\u003e \u003ctd\u003e Character[1 byte]   \u003c/td\u003e\u003ctd\u003e  Binary codeword String Form[MAX bytes]  \u003c/td\u003e \u003c/tr\u003e\n\u003ctr\u003e \u003ctd colspan=\"2\"\u003e              N times                                       \u003c/td\u003e \u003c/tr\u003e\n\u003ctr\u003e \u003ctd\u003e p (1 byte)          \u003c/td\u003e\u003ctd\u003e p times 0's (p bits)                     \u003c/td\u003e \u003c/tr\u003e\n\u003ctr\u003e \u003ctd colspan=\"2\"\u003e  DATA                                                      \u003c/td\u003e \u003c/tr\u003e\n\u003c/table\u003e\n\np = Padding done to ensure file fits in whole number of bytes. eg, file of 4 bytes + 3 bits must ne padded by 5 bits to make it 5 bytes.\n\nExample\n----------------------------\nText: aabcbaab\n\n| Content                           | Comment                               |\n|-----------------------------------|---------------------------------------|\n|3                                  | N=3 (a,b,c)                           |\n|a \"1\"                              | character and corresponding code \"1\"  |\n|b \"01\"                             | character and corresponding code \"01\" |\n|c \"00\"                             | character and corresponding code \"00\" |\n|4              \t\t    | Padding count                         |\n|[0000] \t\t\t\t    | Padding 4 zeroes                      |\n|[1] [1] [01] [00] [01] [1] [1] [01]| Actual data, code in place of char    |\n\nAlgorithm\n============================\n0. **(Pass 1)** Read input file\n0. Create sorted linked list of characters from file, as per character frequency\n   ```\n   for eah character ch from file\n\n\tif( ch available in linked list at node p) then \n\t{\n\t\tp.freq++;\n\t\tsort Linked list as per node's freq;\n\t}\n\telse\n\t\tadd new node at beginning of linked list with frequency=1;\n   ```\n0. Construct huffman tree from linked list\n   0. Create new node q, join two least freq nodes to its left and right\n   0. Insert created node q into ascending list\n   0. Repeat i \u0026 ii till only one nodes remains, i.e, ROOT of h-tree\n   0. Traverse tree in preorder mark each node with its codeword. simultaneously Recreate linked list of leaf nodes.\n0. Write Mapping Table(character to codeword) to output file.\n0. **(Pass 2)** Read input file.\n0. Write codeword in place of each character in input file to output file\n   for each character ch from input file\n\twrite corresponding codeword into o/p file (lookup in mapping table OR linked list)\n0. End\n\nContributing\n============\n\nPlease feel free to submit issues and pull requests. I appreciate bug reports.\nTesting on different platforms is especially appreciated. I only tested on Linux.\n\nLicense\n=======\n[MIT](https://opensource.org/licenses/MIT)\n\n\nDevelopment\n===========\n\nTo do:\n* Binary files, like jpeg,mp3 support\n* Run scan to group repeating bit patterns, not bit.\n* Unicode support\n* Move entire codebase to python, use neural network to compress files.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsspeedy99%2Ffile-compression","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsspeedy99%2Ffile-compression","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsspeedy99%2Ffile-compression/lists"}