kap
BAN USER- 0of 0 votes
AnswersFor example, give the letter (p,o) and length of 3, produce the following output(in any order you want, not just my example order)
- kap in India
ppp ppo poo pop opp opo oop ooo
another example would be given (a,b) and length 2
answer: ab aa bb ba| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Coding - 0of 0 votes
AnswersMinimum/Maximum Sum path in A Binary Tree
- kap in India
Find and Print the Root to leaf path with minimum sum.
Finding such a path is easy bt how to print only that path..
u can not modify structure of tree node..it has a data with left and right child pointers.
Use as minimum space as possible| Report Duplicate | Flag | PURGE
Amazon Developer Program Engineer Algorithm
please check if dis works or not
bool hasPathSum(struct node* node, int sum)
{
/* return true if we run out of tree and sum==0 */
if (node == NULL)
{
return(sum == 0);
}
else
{
int subSum = sum - node->data;
return(hasPathSum(node->left, subSum) ||
hasPathSum(node->right,subSum)||
hasPathSum(node->right,sum)||
hasPathSum(node->left, sum));
}
}
bt count sort can be done only if we have a specified range..here no range is given
- kap October 09, 2011