http://www.geeksforgeeks.org/a-program-to-check-if-a-binary-tree-is-bst-or-not/
Thursday, December 12, 2013
Wednesday, December 11, 2013
Thursday, December 5, 2013
Remove all nodes which don’t lie in any path with sum>= k
1) pass sum of root to its children
2) compare at each level wether we have got desired sum
{
i) if yes, return true from that node
ii) else check if node is leaf node
{
a) if its a leaf node & sum is not desired one return false
}
pass sum upto this node to left subtree
if left subtree return false
remove left subtree node
pass sum upto this node to right subtree
if right subtree return false
remove right subtree node
if either of subtree has return tree
return true
else
return false
Wednesday, December 4, 2013
Subscribe to:
Posts (Atom)