Constructed binary tree is 10 / \ 8 2 / \ / 3 5 2
GFG tree = new GFG ( ) ; tree . root = new Node ( 10 ) ; tree . root . left = new Node ( 8 ) ; tree . root . right = new Node ( 2 ) ; tree . root . left . left = new Node ( 3 ) ; tree . root . left . right = new Node ( 5 ) ; tree . root . right . left = new Node ( 2 ) ; if ( tree . haspathSum ( tree . root , sum ) ) { Console . WriteLine ( " There ▁ is ▁ a ▁ root ▁ to ▁ leaf ▁ " + " path ▁ with ▁ sum ▁ " + sum ) ; } else { Console . WriteLine ( " There ▁ is ▁ no ▁ root ▁ to ▁ leaf ▁ " + " path ▁ with ▁ sum ▁ " + sum ) ; } } }