I don't think you want to push the new node into a queue,
you want the nodes in order of size, so a heap may be a more appropriate data structure than a queue
Main Topics
Browse All TopicsHello,
I am working on creating a Huffman Code (tree). I currently read all symbols and frequencies from a file into Nodes, stored in an array of node *'s, then I sort the array based on frequency and push the sorted nodes into a queue. Now when I try to combine the Nodes I receive and error. I pop the first to nodes from queue and have temp vairables for them, I create a new node and combine the frequencies and alpha characters. However when I try to push the new node back into the queue I receive error message: "deque iteration not referencable".
Please tell me how I can fix this, so that I can pop and push to the same queue?
I created another queue and I am able to push the node * to that queue, so I know it is a problem with accessing the same queue I am popping from. Can someone tell me how I can push a node * back into the same queue?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I fixed the initial problem by changing the while loop logic. I corrected the tree's nodes being out of order, by sorting the queue until there was only one node left in the queue. popped two elements, combined them, push new node to the queue, moved queue elements to the array, sorted the array and requed all elements in the array, started pops over again.
Infininty, yes, you are right, seems like I should have been one character short, however when all nodes are combined I am able to hold the string concatenation. I am not sure why this worked.
In case anyone is interested here is my completed code
Business Accounts
Answer for Membership
by: Middletown_TechPosted on 2009-04-09 at 14:13:43ID: 24111730
I had this function called commented out //enQueue(node_position);
but it shouldn't have been I was experimenting when I posted the question. Please uncomment if you try to compile