Re: [algogeeks] print all paths which sum up to a value.

2011-08-25 Thread arjoo kumar
this is C++ programme bool hasSum(struct node **head , int sum){ if ((*head ) == NULL) return (sum == 0) else { sum = sum -*(head)->data; hasSum(&(*head)->left , int sum); hasSum(&(*head)->right , int sum) ; }

[algogeeks] print all paths which sum up to a value.

2011-08-19 Thread MAC
can someone explain how to solve this: You are given a binary tree in which each node contains a value. Design an algorithm to print all paths which sum up to that value. Note that it can be any path in the tree - it does not have to start at the root. (please write how to solve it i.e. logic u c