C++ Program to develop a Huffman Tree

  • Status: Closed
  • Prize: $25
  • Entries Received: 2
  • Winner: iit2009013

Contest Brief

Write a C++ program to develop a Huffman Tree. First you must prompt the user to enter up to 10 letters (from a to z) and the frequency for each letter (the total sum of the frequencies add up to 100). Then create a node for each letter using a struct called node (you must determine what the data types are).

Struct node {
to be implemented………….
}

Insert the nodes of each character into a MinHeap (in class we defined the class MaxHeap, thus use the same class but make sure you change the inequalities from ≤ to ≥ or vice versa) where minimality is with respect to the frequency. The heap is an array of nodes.

1) Delete the first 2 nodes from the heap (using the delete function of the heap class) and create another node where the frequency of the node is the sum of the frequencies of the deleted nodes.
Set address of the new node as the address determined by the new operator.
Add the address of the father node to the deleted nodes. Also set child = ‘L’ for the first deleted node and “R” to the second deleted node.

Repeat step 1) until the heap is empty (remember at the end the final node must have frequency equals to100 and this node is the Huffman tree).

Thus the final Huffman tree looks like the tree in Fig 1.

To determine the code for each letter, starting at the node corresponding to a letter, trace back to the root, and if a node is the leftchild of another node add a 0 to the code and add a 1 otherwise (in reverse order), and go to the father node until the root is reached.

I have attached project details for your reference.

Recommended Skills

Public Clarification Board

  • iit2009013
    iit2009013
    • 11 years ago

    I already have a code developed for this. My code displays the frequency of each character, codes generated for each character and finally the decoded word. It also has the option to decode the encoded codeword. I can it to you immediately for $25. Let me know if interested.

    • 11 years ago
    1. ysrikanth3000
      Contest Holder
      • 11 years ago

      As mentioned in the Project description, the sum of frequencies to the given string must be 100. can you please do that modification in the code???

      • 11 years ago
  • it2051229
    it2051229
    • 11 years ago

    Already did this. Let me know if you are interested.

    • 11 years ago
    1. it2051229
      it2051229
      • 11 years ago

      The things is I don't do contents in freelancer.com I do projects as awarded.

      • 11 years ago
    2. it2051229
      it2051229
      • 11 years ago

      *don't do contests

      • 11 years ago
  • Ruchi003
    Ruchi003
    • 11 years ago

    do you want graphical representation of the heap?
    like in the file?

    • 11 years ago
    1. ysrikanth3000
      Contest Holder
      • 11 years ago

      yes

      • 11 years ago
  • umarmughal824
    umarmughal824
    • 11 years ago

    I can do it very easily within your given time.

    • 11 years ago
  • PeinOS
    PeinOS
    • 11 years ago

    Hello, I can do this task

    • 11 years ago
  • rishu2231
    rishu2231
    • 11 years ago

    i will complete this project with in 24 hours .....
    currently, i am working as Asst Prof in Engineering college.
    Sandeep Srivastava
    M.tech in Computer science.

    http://www.secs.ac.in/faculty.html
    you can see.
    online on freelancer at 9:00 am to 4:00pm and then 9:00 PM to 11:30pm (indian time )

    • 11 years ago
    1. ysrikanth3000
      Contest Holder
      • 11 years ago

      ok but let me know the project amount @rishu2231

      • 11 years ago
  • Venky117
    Venky117
    • 11 years ago

    hi... i can do this ASAP.

    • 11 years ago
  • ysrikanth3000
    Contest Holder
    • 11 years ago

    tell me the amount how much u will charge for it

    • 11 years ago
  • umarbsse
    umarbsse
    • 11 years ago

    Go to my profile and invite me i can do that task within 24 hours

    • 11 years ago
    1. ysrikanth3000
      Contest Holder
      • 11 years ago

      ok can u tell me the project amount

      • 11 years ago
  • Imranceo
    Imranceo
    • 11 years ago

    I can do this if you award me project thanks

    • 11 years ago

Show more comments

How to get started with contests

  • Post your contest

    Post Your Contest Quick and easy

  • Get tons of entries

    Get Tons of Entries From around the world

  • Award the best entry

    Award the best entry Download the files - Easy!

Post a Contest Now or Join us Today!