Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement compression and decompression for Huffman coding #39658

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

mashraf8
Copy link

@mashraf8 mashraf8 commented Mar 9, 2025

This PR introduces two new methods, compress_encoded and decompress_encoded, to improve Huffman encoding efficiency. The problem stems from that encoded binary strings are often long to store or transmit efficiently.

The compress_encoded method ensures that an encoded binary string is padded to a multiple of 8 and then converts every 8-bit chunk into a single character. The decompress_encoded method reverses this process by converting characters back into their corresponding binary representation and removing the added padding.

These changes enhance storage efficiency while maintaining lossless reconstruction of the original data. Doctests confirm the correctness of the implementation, ensuring that encoding, compression, decompression, and decoding operations preserve the original input.

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant