0

Here is some of the code I have - My issue is in the generateTable() function:

I have created a Huffman Code tree and I want to output each node's location so that it appears like so:

10 111100
32 110
33 1010110110
34 10101111
38 01100110110101110011
39 1110101011
40 1010110111011101
41 011001101101010

Why won't that function write to the file properly? (I ask because that code was provided to me by my professor and I don't understand the problem.) When I open the file it is empty.

somebody
  • 85
  • 3
  • 10
  • Don't change the question once it's been answered. if you do no one can retrace your steps if they have the same question. – jfa Apr 17 '14 at 00:47
  • Sadly it wasn't answered on here despite a large number of views - but I understand where you're coming from. – somebody Apr 17 '14 at 12:16
  • Removing the code you asked a question about isn't going to make it more likely to be answered. We're more than willing to look at your problem **and** help you narrow down what your actual question is, but we do need your code for that. Try to be clear about what already works and what doesn't in the code you provide, that helps a lot. – Energya Apr 28 '14 at 18:46

1 Answers1

1

If this is the exact code that was provided to you, then you should probably implement the orderNodes and readFileIn functions. They currently do nothing besides returning the empty ArrayHeap that is created in the line before they are called.

Also, I'm surprised that HTree.generateTable(...) even works, as it is not instantiated as an instance of HuffManNode (as far as I can see)

Energya
  • 2,623
  • 2
  • 19
  • 24
  • I removed a lot of code that wasn't needed for this question - only that function is malfunctioning, and that is the only function he provided (along with its call). generateTable and codeTable don't work - that's the problem. That whole block of code should write to a file like I put below but they don't. They do nothing. – somebody Apr 16 '14 at 23:10
  • He clearly gave me a broken function but I haven't any idea how to fix it. I'm quite sure there are a few names that need to be changed but I feel like I've tried everything. – somebody Apr 16 '14 at 23:17