Click here to Skip to main content
Licence 
First Posted 11 Nov 2002
Views 46,716
Bookmarked 20 times

n-ary Huffman Template Algorithm

By | 12 Nov 2002 | Article
The algorithm allows any kind of weights (costs, frequencies), including non-numerical ones

Introduction

Web page :
http://alexvn.freeservers.com/s1/huffman_template_algorithm.html

Download :
http://www.simtel.net/pub/pd/60300.shtml
http://home.barak-online.net/alexvn/s2/hf/hufnta22.zip



The algorithm allows any kind of weights (costs, frequencies), including non-numerical ones. The {0, 1, ..., n-1} alphabet is used to encode message. Built tree is n-ary one.

The algorithm is based on a set of template classes :
- Cell(SYMBOL, WEIGHT),
- Node(SYMBOL, WEIGHT),
- InternalNode(SYMBOL, WEIGHT),
- TerminalNode(SYMBOL, WEIGHT),
- BasicHuffmanTree(SYMBOL, WEIGHT, ARY),
- LoadedHuffmanTree(SYMBOL, WEIGHT, ARITY),
- DriedHuffmanTree(WEIGHT, ARITY).
The user should use only LoadedHuffmanTree and/or DriedHuffmanTree classes.
LoadedHuffmanTree requires (as input data) the symbols and their weights.
DriedHuffmanTree requires (as input data) only the weights.

The program contains the following tests :
* Creating Loaded 5-ary Huffman Tree from data vector with char-symbols and int-weights;
* Creating Loaded 24-ary Huffman Tree from data vector with char-symbols and int-weights;
* Creating Loaded Binary Huffman Tree from data vector with char-symbols and int-weights;
* Creating Dried (Unloaded) Binary Huffman Tree from data vector with int-weights (Fibonacci sequence);
* Creating Dried (Unloaded) Binary Huffman Tree from data file with int-weights;
* Creating Loaded Binary Huffman Tree from data file with char-symbols and int-weights;
* Creating Loaded Binary Huffman Tree from data vector with string-symbols and float-weights;
* Creating Loaded Binary Huffman Tree from data vector with AAA-symbols and BBB-weights;
* Encoding and Decoding vector-message using 5-ary Huffman Tree;
* Encoding and Decoding string-message using 5-ary Huffman Tree;
* Encoding and Decoding vector-message using Binary Huffman Tree;
* Encoding and Decoding string-message using Binary Huffman Tree



Source :
http://groups.google.com/groups?th=f9bb13f7426e888c

Raw run log (Demo) :
http://groups.google.com/groups?th=7daf90d4f66a47ad

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Alex Vinokur

Web Developer

Israel Israel

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 1 PinmemberBen_Desjardins4:13 22 Jan '09  
GeneralIt would be nice PinmemberJörgen Sigvardsson9:51 13 Nov '02  
GeneralRe: It would be nice PinmemberAlex Vinokur18:28 13 Nov '02  
GeneralThis is a link... PinmemberDaniel Turini23:07 12 Nov '02  
GeneralRe: This is a link... PinmemberAlex Vinokur6:07 13 Nov '02  
GeneralRe: This is a link... Pinsussrobinds3:33 14 Nov '02  
GeneralRe: This is a link... PinmemberAlex Vinokur5:51 14 Nov '02  
GeneralRe: This is a link... PinmemberSimonR21:28 21 Jan '04  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 13 Nov 2002
Article Copyright 2002 by Alex Vinokur
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid