void inorderTrav(struct TreeNode *root)
{
    if(!root) {
        return ;
    }
    printf("%d\n", root->val);
    inorderTrav(root->left);
    inorderTrav(root->right);
}
int main()
{

    int arr[] = {1,2,3,4,5,6,7};
    struct TreeNode *r = sortedArrayToBST(arr, 7);
    inorderTrav(r);
    return 0;
}
Example #3
0
void BST<Item, Key>::inorder(Function m) {
	inorderTrav(root,m);
}
Example #4
0
void BST<Item, Key>::inorderTrav(Node* ptr,Function n) {
	if (ptr == NULL) return;
	inorderTrav(ptr->left,n);
	n(ptr->data);
	inorderTrav(ptr->right,n);
}