Let us construct the following Tree 50 / \ 10 60 / \ / \ 5 20 70 70 / \ / \ 65 80 65 80
Node * root = newNode ( 50 ) ; root -> left = newNode ( 10 ) ; root -> right = newNode ( 60 ) ; root -> left -> left = newNode ( 5 ) ; root -> left -> right = newNode ( 20 ) ; root -> right -> left = newNode ( 70 ) ; root -> right -> left -> left = newNode ( 65 ) ; root -> right -> left -> right = newNode ( 80 ) ; root -> right -> right = newNode ( 70 ) ; root -> right -> right -> left = newNode ( 65 ) ; root -> right -> right -> right = newNode ( 80 ) ; Node * maxNode = NULL ; int maxSize = largestSubtree ( root , maxNode ) ; cout << " Largest ▁ Subtree ▁ is ▁ rooted ▁ at ▁ node ▁ " << maxNode -> data << " and its size is " << maxSize ; return 0 ; }