


















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



















































TREE t;
t = NULL;
t t^ NULL t 2 N N
t 2 4 7
int value(TREE t) { if (isEmptyTree(t)) { printf(“Tree is empty\n”); return -1; } else return t->data; } TREE mkEmpty(void) /* return an empty tree */ { return NULL; }
TREE mkTree(int x, TREE leftT, TREE rightT) /* make a new tree from a data value x and two existing trees */ { TREE temp; temp = malloc(sizeof(TREENODE)); temp->data = x; temp->leftptr = leftT; temp->rightptr = rightT; return temp; }
int size(TREE t) { if (isEmptyTree(t)) return 0; else return (1 + size(lsTree(t))
height of tree height of tree
int height(TREE t) { if(isEmptyTree(t)) return 0; else return (1 + max(height(lsTree(t)), height(rsTree(t)))); }