0

Hello friends,

i am doing programs in c++....and think that my progress is good .. but here is very serious problem with me ..i need a c++ graphics simulation source code for generating huffman tree....plz if you peple know any link for source code or have that program ....let me know abt that.....

yes am agree that i am asking you source code but it is my compulsion that

i badly need it..plz plz help me........................

thankx in advance

3
Contributors
2
Replies
3
Views
11 Years
Discussion Span
Last Post by orko
0

Nope, you don't need no fancy graphics library to draw a tree. Ascii will suffice.

Example
Let's say for the sake of brevity our huffman tree is as follows:

P
      /  \
     e    d
        / | \
       a  n  t
         / \
        i   c

which may be represented as:

P(e,d(a,n(i,c)t))

...Using, of course, a binary tree to hold the data, which I'm sure you already know.


Then using these basic characters below we can draw our tree:-

├    = char 195

│   = char 179

└   = char 192

─   = char 196
P
├─e
└─d
  ├─a
  ├─n
  │ ├─i
  │ └─c
  └─t

It's just a case of recursively expanding your binary tree from the root node, and applying some common sense to reserve space for the relevant characters.

Get it?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.