Constructing tree given in the above figure
tree . root = new Node ( 10 ) ; tree . root . left = new Node ( - 2 ) ; tree . root . right = new Node ( 6 ) ; tree . root . left . left = new Node ( 8 ) ; tree . root . left . right = new Node ( - 4 ) ; tree . root . right . left = new Node ( 7 ) ; tree . root . right . right = new Node ( 5 ) ; tree . toSumTree ( tree . root ) ;