Just call a function

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
/* Basic structure of the node of a BST */
struct node{
    int data;
    node* left; 
    node* right;
};
/* A function to print all the data of a BST    */
void print(node* Tree){
    if(Tree){
        print(Tree->left);
        cout<<Tree->data<<" ";
        print(Tree->right);
    }
}

What is the number of function calls for the recursive function print(node* Tree) to print the data of the BST in the picture above ?

Bonus: How can you generalize your solution for any BST ?

×

Problem Loading...

Note Loading...

Set Loading...