void AvlTree::nodePrint(Node* rootnode , int dir , int data){ if (rootnode == NULL){ return; } if (dir == 0){ printf("%d is the root\n" , data); }else{ printf("%d is %d's %s child \n" , rootnode -> data , data , dir == 1?"right" : "left"); } nodePrint(rootnode -> left , -1 , rootnode -> data); nodePrint(rootnode -> right , 1 , rootnode -> data); }
/*-----------*/ void nodePrint(node* v) { if(!v){ return; } if(v->nid == 0){ printf("node(%d) --> root x = %f y = %f\n",v->nid,v->x,v->y); } else{ int nquad = nodeQuadrant(v); printf("node(%d): x = %f y = %f --> Q = %d, P = %d\n",v->nid,v->x,v->y,nquad,v->pnode->nid); } nodePrint(v->cnodeNE); nodePrint(v->cnodeNW); nodePrint(v->cnodeSW); nodePrint(v->cnodeSE); }