Hi everyone,

I'd like to ask you all to help me with this two questions and I've been faced recently,

1.What would be the algorithm which takes the pointers of two Binary Search Trees roots, if equal returns true if not FALSE. (both BSTs are the same as well as the corresponding nodes.)?

  1. how many times does " cout " execute?

    int m=0;
    for(int i=1; i<=n; i++)
    {
    m=m+i;
    for(int j=1; j<=m ; j++ )
    cout << j;
    }

thank you all for you helps and replies in advance.

Hi,

  1. This algorithme will have a O(n) complexity : you will check all the tree, so the "binary" particularity doesn't change things.
  2. cout excutes :
    1+3+6+10+15+21+...
    Sum of (1+m)(m/2) and m changes from 1 to n
    To simplify, it will b a O(n³) (I think)