You have binary tree with all but one numbers from n to m. You need to find the missing number..
E.g. given a binary tree with all numbers from 10 to 100 except one in that 10-100 range. Find the the missing number
u may take boolean array, index them accordingly,and in traversal of tree mark the presence as 1 ,so at last u will get the unmark elements as missing. I think in this way u can get more than one missing elements also
let count = sum(10 to 100) is prone to integer overflow
let count = sum (10 to 100)
traverse the tree (any inorder, postorder watever) at each node do count = count - node-> data;
finally what is left in the count is the number missing.
may be a solution
u may take boolean array, index them accordingly,and in traversal of tree mark the presence as 1 ,so at last u will get the unmark elements as missing.
I think in this way u can get more than one missing elements also
Missing element in a binary tree
let count = sum(10 to 100) is prone to integer overflow
Missing element in a binary tree
let count = sum (10 to 100)
traverse the tree (any inorder, postorder watever) at each node do
count = count - node-> data;
finally what is left in the count is the number missing.