int height1(struct node *p) { int a, b; if (p == NULL) return 0; a = height1(p->left); b = height1(p->right); if (a >= b) return a + 1; else return b + 1; }
int height1(struct node* node) { if (node == NULL) return 0; else { int lheight = height1(node->left); int rheight = height1(node->right); if (lheight > rheight) return(lheight + 1); else return(rheight + 1); } }
int* BSTRighttoLeftRows(struct node* root) { if (root == NULL) return 0; int n = count1(root); int *array = (int*)malloc(sizeof(int)*n); int h = height1(root); int i, index = 0; for (i = 1; i <= h; i++) printLevel(root, i, array, &index); return array; }
int height() { return height1(root); }