snehit.gajjar
BAN USER
Questions (2)
Comments (4)
Reputation 15
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
Hi Vir Pratap, it is not just for binary tree. There can be any number of child node for any node.
- snehit.gajjar June 25, 2015Comment hidden because of low score. Click to expand.
0
of 0 vote
sorry it can have any number of child node. It can be stored in list or something. There is no restriction on number of node in any level.
- snehit.gajjar June 25, 2015Comment hidden because of low score. Click to expand.
0
of 0 vote
public static boolean isSameInOrder(Tree t1, Tree t2){
boolean isTrue=false;
if(t1.value==t2.value){
isTrue=true;
if(t1.leftTree!=null && t2.leftTree!=null ){
isTrue = isSameInOrder(t1.leftTree,t2.leftTree);
}
if(t1.rightTree!=null && t2.rightTree!=null ){
isTrue = isSameInOrder(t1.rightTree,t2.rightTree);
}
}
else{
isTrue=false;
}
return isTrue;
}
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
You did it only for two child node. Question is that each node can have any number of child.
- snehit.gajjar June 30, 2015