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

Recommended Answers

All 2 Replies

Member Avatar for iamthwee

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?

wow! it will help me too! :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.