codezonediitj / pydatastructs

A python package for data structures and algorithms
https://pydatastructs.readthedocs.io/en/stable/
Other
201 stars 269 forks source link

Huffman Coding #260

Open poojithamiryala opened 4 years ago

poojithamiryala commented 4 years ago

Description of the problem

Given a set of symbols along with their frequencies, we will find a variable-length binary code that can be assigned to each and every symbol. The main objective of this algorithm is to usually transmit information using the fewest number of bits in such a way that every encoding is unambiguous.

Expectations: Time Complexity:O(nlogn)

Methods:

  1. buildHuffmanTree(symbolsWithFrequencies)
  2. generateHuffmanCodes(rootOfHuffmanTree)

Example of the problem

References/Other comments

https://en.wikipedia.org/wiki/Huffman_coding

czgdp1807 commented 4 years ago

Not an urgent need.

shivangdubey commented 3 years ago

Input: String X Initialize priority queue: Q c: character in string X Algorithm:

  1. while len(Q) > 1; (f1, T1) = Q.remove_min() (f2, T2) = Q.remove_min() Creating subtree T1(left) and T2(right) in T and inserting T into Q with key f1 + f2. (f, T) = Q.remove_min() return tree T

@czgdp1807 If this looks good, should I implement and make a PR?

czgdp1807 commented 3 years ago

Can you define a more concrete API, like how would I call a function to obtain the huffman encoding?

P.S. - This is not an urgent need, so may not receive much attention.

Riope commented 3 years ago

I am interested to work on this issue.

RhuthuHegde commented 3 years ago

Can I work on this issue?

Smit-create commented 3 years ago

Can I work on this issue?

Feel free to work on it. Please provide the implementation/API plan below in the comments

skywalker2207 commented 1 year ago

can i work on it ?