Skip to content

Create Huffman_Coding.py #279

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

Merged
merged 5 commits into from
Oct 3, 2020
Merged

Create Huffman_Coding.py #279

merged 5 commits into from
Oct 3, 2020

Conversation

ASHMITA-DE
Copy link
Contributor

Python implementation of Huffman Coding using Greedy Approach

Thank you for your contribution. Please provide the details requested below.

ISSUE NUMBER

#279

SHORT DESCRIPTION

Huffman Coding is a technique of compressing data to reduce its size without loss of data. It is generally useful to compress the data in which there are frequently occurring characters.
It follows a Greedy approach since it deals with generating minimum length prefix-free binary codes.
It uses variable-length encoding scheme for assigning binary codes to characters depending on how frequently they occur in the given text.
Priority Queue is used for building the Huffman tree such that the character that occurs most frequently is assigned the smallest code and the one that occurs least frequently gets the largest code.
It follows this procedure: -
Create a leaf node for each character and build a min heap using all the nodes (The frequency value is used to compare two nodes in min heap)
Repeat Steps 3 to 5 while heap has more than one node
Extract two nodes, say x and y, with minimum frequency from the heap
Create a new internal node z with x as its left child and y as its right child. Also frequency(z)= frequency(x)+frequency(y)
Add z to min heap
Last node in the heap is the root of Huffman tree

TESTING

Just run it on any IDE.

Python implementation of Huffman Coding using Greedy Approach
@ASHMITA-DE
Copy link
Contributor Author

Python implementation of Huffman Coding using Greedy Approach

@indrarahul
Copy link
Member

@ASHMITA-DE Please look into the file structure. Create a Huffman Coding folder inside Greedy, put your code there.

@ASHMITA-DE
Copy link
Contributor Author

@ASHMITA-DE Please look into the file structure. Create a Huffman Coding folder inside Greedy, put your code there.

Done.

@ASHMITA-DE
Copy link
Contributor Author

ASHMITA-DE commented Oct 2, 2020 via email

@indrarahul indrarahul merged commit 85e3fee into codeIIEST:master Oct 3, 2020
@ASHMITA-DE
Copy link
Contributor Author

@indrarahul2013 , could you please classify the repository as ‘hacktoberfest’ eligible. Thank you.

@ASHMITA-DE
Copy link
Contributor Author

@indrarahul2013 , as per the new rules of Hacktoberfest 2020, could you please label this pull request as "hacktoberfest-accepted"? Thank you.

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

Successfully merging this pull request may close these issues.

2 participants