sai s
BAN USER
Comments (3)
Reputation 20
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
recursivedepth(valueh,root)
{
valueh++;
if(valueh >height)
{
height=valueh;
}
if(root.lchild !=null)
{
recursivedepth(valueh,root.lchild);
}
if(root.rchild !=null)
{
recursivedepth(valueh,root.rchild);
}
}
I donno whether this is the optimal solution for this problem are can come up with some other
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
without sorting can we just add the first element to all the elements one by one and store the values in the hash map,and the second with third and soon upto last element.till n-1 elemnts and store the values in the hash table.this hash table may need o(n(n-1)/2) time to construct but than the look up for any sum would be just o(1) times.
- sai s February 05, 2013please,let me know if i am wrong.thanks in advance