function to update count in max heap, seg fault

Can anyone figure out why this is giving me a segmentation fault whenever it is ran? This is for use in a max heap
1
2
3
4
5
6
7
8
9
template <class T>
void Heap<T>::countUp(BNode <T>* newnode)
{
  if ((newnode != NULL) || (newnode->m_parent != NULL)){
    newnode->m_parent->m_count++;
    countUp(newnode->m_parent);
  }

}


I'm running this at the bottom of my insertion function. It (should) take the newly inserted node as the parameter, then update its parent node's count(number of nodes below it + itself) to refect the addition of the new node, and recurse up the tree till the top.
Try changing the || to a && ?
Last edited on
long double main.. nope, sorry, didn't work :(
Topic archived. No new replies allowed.