Application of Huffman tree (data structure)

Source: Internet
Author: User

Application of Huffman tree :

1. Select an article First

2. Then count the number of characters

3, the number is not 0 characters to encode

4. Output code text

5, the decoding

On-Machine code:

/*************************************************************************> File Name:huffman tree application. cpp > Author:zzuspy> Mail: [email protected] > Created time:2014 December 3 14:30 *********************************** /#include <cstdio> #include <cstring> #include <iostream># Include <algorithm> #include <cstdlib> #include <cmath> #include <stack> #include <queue> #define LL Long Long#define max3 (a,b,c) max (A,max (b,c)) #define MIN3 (a,b,c) min (a,min (b,c)) using namespace Std;typedef Struct{int weight;int Parent, Lchild, Rchild;} Htnode, *huffmantree;typedef char * * huffmancode;int s1, s2;void Select (huffmantree &ht, int n) {int i, min;for (int i= 1; i<=n; i++) {if (ht[i].parent==0) {min = i;break;}} for (I=1; i<=n; i++) {if (ht[i].weight

Application of Huffman tree (data structure)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.