Here is the heap I am looking at,
As you can see from the heap tree, the order of the nodes are everywhere. The number 1 is on the right side and the number 2 is bottom left. How would I make it so I can output those numbers in order?
This is a discussion on How would we output from smallest to largest in a heap data stucture? within the C++ Programming forums, part of the General Programming Boards category; Here is the heap I am looking at, As you can see from the heap tree, the order of the ...
Here is the heap I am looking at,
As you can see from the heap tree, the order of the nodes are everywhere. The number 1 is on the right side and the number 2 is bottom left. How would I make it so I can output those numbers in order?
Sort it.
"All that we see or seem
Is but a dream within a dream." - Poe
Step 1: Begin by NOT storing the values in a largest-first heap. That's like jumping out of an airplane with SCUBA gear instead of a parachute.
(More helpfully, had you used a smallest-first heap instead of a largest-first heap, you'd only be a heap-sort away from solving the problem.)
Code://try //{ if (a) do { f( b); } while(1); else do { f(!b); } while(1); //}