Okay, I think I know now what I did wrong. It's the one that generates the Huffman tree before encoding the characters into their unique code, because I don't have the function to sort the nodes in the first queue after putting a new node that has the sum of the two smallest nodes in the first queue into the second queue (as another way of implementing besides a priority queue Huffman coding). Therefore, what happens is that 01 in a bit string will always print out 'e' in the decoding part. Below is the function that generates the two queue-cursor Huffman Coding Tree:
void generateHuffman (Queue& q1, Queue& q2)
input - an initial sorted queue q1 of the frequencies of each character
output - a sorted list q2 composed where every node is the sum of two
elements in q1 and has cursors in each one of these.
QueueNode *leftChild, *rightChild, *tempNode;
char tempChar = q1.frontNode()->value;
rightChild = q1.backNode();
tempChar = q1.frontNode()->value;
leftChild = q1.backNode();
while (q1.back() <= q1.front())
@pre: q1 has all the elements sorted
@post: all elements in q1 will be back in place with each of them referenced
by elements in q2 */
q2.enqueue( q1.front()+q2.front() );
tempNode = q2.backNode();
tempNode->rightCursor = q2.backNode();
tempChar = q1.frontNode()->value;
tempNode->leftCursor = q1.backNode();
while( q2.frontNode() != tempNode)
tempNode = NULL;
I was trying to have a compare function for this, so that I can use the STL sort the way I did with the list of character frequencies in an array. What do you think. Is there any way that this can be better improved. Please help, thank you.
I need to know , for CListCtrlEx::OnNMCustomdraw(...) if list control have LVS_EX_FULLROWSELECT AND LVS_EX_GRIDLINES extended style ... my question is , there is a method to find that in single line of code ? I try this :
And one more thing : it's a good ideea to check that ( have 2 extended style ) in OnNMCustomdraw(...) in above style ? Or it be good thing to set up a variable that know if list control have both extended style ?
Don't forget that it is possible to set the CListCtrl style after it has been created. So to be safe, you should check the style right before you need to use it, rather than store it in a variable only once.
I am trying to find out how to check the 'check' state of a node in a TreeView control using C# in an ASP.NET application. Basically, I have a TreeView control that shows checkboxes. The user makes a selection which I want to store in a session variable upon a 'submit' button click. I use a 'TreeView.Node.Checked' statement to verify whether the user selected that node. This, however, does not work because the selection is made at the client side and when it gets posted to the server, the 'TreeView.Node.Checked' statement, whether selected or not, will always return 'false' for any node. Does anyone have a solution for this? Thx,
Is it possible for a void function that outputs characters using the cout<< extraction statement be able to put its results into a specific file via an ofstream variable, and if yes then what function should I use?
Basically, it outputs a binary string representation of a character. What I want to do now is to transfer each of these output bits into a file with a use of an ofstream function. Any ideas on how to do this?
can i make the folder which of default to any file type ...
i had idea that if possible to convert the directory to a file format which have the unique extension so that when double clicked it will ask the password ...
actually i am doing the project on the folder security