Here is the simple code for converting a BST to array of numbers:
/* Converting a BST into an Array */
void TreeToArray(struct Tree *node, int a[]){
static int pos = 0;
if(node){
TreeToArray(node->left,a);
a[pos++] = node->data;
TreeToArray(node->right,a);
}
}
For other tree operations and complete code refer to : click here
No comments:
Post a Comment