codeIIEST / Algorithms

A Repository to store implementation of some of the famous Data Structures and Algorithms (mainly in C/C++/Java/Python) for everyone to learn and contribute.
http://codeiiest.github.io/Algorithms/
MIT License
203 stars 163 forks source link

Create Huffman_Coding.py #279

Closed ASHMITA-DE closed 4 years ago

ASHMITA-DE commented 4 years ago

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.

ASHMITA-DE commented 4 years ago

Python implementation of Huffman Coding using Greedy Approach

indrarahul commented 4 years ago

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

ASHMITA-DE commented 4 years ago

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

Done.

ASHMITA-DE commented 4 years ago

Done

https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail Virus-free. www.avast.com https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Fri, Oct 2, 2020 at 7:51 AM Rahul Indra notifications@github.com wrote:

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

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/codeIIEST/Algorithms/pull/279#issuecomment-702491808, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOI5FFH222V4FBJFMD7ICTDSIU2K5ANCNFSM4SAYTSBQ .

ASHMITA-DE commented 4 years ago

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

ASHMITA-DE commented 4 years ago

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