I want to know why huffman encoding comes under greedy algorithm? how they both are realted to each other??..and please send the code of this if you have?
Huffman Encoding Algorithm
the given codes are selected greedily since the assigned codes are based on the algorithm of rope joining which is greedy
okay!!..talking about connecting n ropes with minimum cost right??
yes, n ropes of different length and connecting each rope costs the same amount as it’s length, the same logic is used here, u mark the alphabets and keep on joining them to form a tree similar as in that problem and mark right branch as 1 and left branch as 0 and then the route from the root to the required leaf in terms of 1s and 0s is it’s huffman code
If your doubt is cleared please mark it as resolved
Thank You