Huffman coding is a lossless data compression algorithm. The idea is to assign variable-length codes to input characters, lengths of the assigned codes are based on the frequencies of corresponding characters. The most frequent character gets the smallest code and the least frequent character gets the largest code.
- react-file-icon
npm install react-file-icon
- react-dropzone
npm install react-dropzone
- lucide-react
npm install lucide-react
- shadcn library: Download the library
https://ui.shadcn.com/docs/installation
- axios
npm install axios
- fastapi
pip install fastapi
- uvicorn
pip install uvicorn
- Clone the repository
- Run the following command in the terminal
a) For frontend:
i)npm install vite --save-dev
ii)bun run dev
b) For backend:uvicorn main:app --reload
- Drop or Select the file you want to compress
- The compressed file is ready to download
- Count the frequency of each character in the input string
- Create a priority queue (heapq) and insert all characters in it
- Pop two nodes from the priority queue and create a new node with a frequency equal to the sum of the frequencies of the two nodes. Insert the new node back into the priority queue
- Repeat step 3 until there is only one node left in the priority queue
- Traverse the tree and assign codes to characters