What do you not get from:
Quote:
parent is the name of the parameter, you should pass in root in the first call to realInsert, as root is the top level parent of the heap.
As to what to pass as parent and newNode. When you first call the realInsert function the parent would be root, from then on when you recurse down, you would use parent->getLeft() or parent->getRight().
Pass in the newNode that was created at the top of insertSpot as the newNode parameter.
|
That means
your call.
realInsert(*ar, i, root, newNode);
While I gave already gave you:
realInsert(ar, i, parent, newNode); // still needs fixing
And did you even check to see what you were copying?
void insertSpot(int option)
{
heapNode *newNode = new heapNode(option);
int arrayValue;
bool isOne = false;
int ar[32];
int i = 31;
counter++;
if(root == NULL)
{
root = newNode;
}
else
{
int arrayValue;
bool isOne = false;
int ar[32];
int i = 31;
int temp = counter;
And lastly, you should remove the comments that say: "//get value", when the function is called "getvalue". Only comment when it makes things more clear.
Just a quick question: how much programming experience do you have?