Thread: pointer help
View Single Post
Old Apr 5th, 2006, 8:13 PM   #65
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 852
Rep Power: 4 The Dark is on a distinguished road
I guess you need to find the last element in the heap in a similar way to the way you did for the insert, except you want to find the last spot, rather than the spot to place a new item. I think this is where testing for left == NULL or right == NULL won't work, you need to check the value of pos == 0 instead.

Note that somewhere you are actually going to have to remove that last element, once you have put its value in the root, you can't just leave it in the heap. You will also need to change the counter value.

Also note that you don't need to pass in root as a parameter to realinsert, as it is a member variable of the heap class.
The Dark is offline   Reply With Quote