Constructed binary tree is 10 / \ 8 2 / \ / 3 5 2
node * root = newnode ( 10 ) ; root -> left = newnode ( 8 ) ; root -> right = newnode ( 2 ) ; root -> left -> left = newnode ( 3 ) ; root -> left -> right = newnode ( 5 ) ; root -> right -> left = newnode ( 2 ) ; if ( hasPathSum ( root , sum ) ) cout << " There ▁ is ▁ a ▁ root - to - leaf ▁ path ▁ with ▁ sum ▁ " << sum ; else cout << " There ▁ is ▁ no ▁ root - to - leaf ▁ path ▁ with ▁ sum ▁ " << sum ; return 0 ; }