A very interesting question. Still awaiting answer so posting again.
What does this method do?
Stuff is a object in java with two members someStuff and anotherStuff
public static Stuff doSomeStuff (Stuff s0, Stuff s1) {
Stuff someStuff = s1.getSomeStuff();
if(someStuff != null){
s1.setSomeStuff(doSomeStuff(null, someStuff));
}
if(s1.getAnotherStuff()==null){
s1.setAnotherStuff(s0);
return s1;
} else {
Stuff myStuff = doSomeStuff(s1,s1.getAnotherStuff());
s1.setAnotherStuff(s0);
return myStuff;
}
}
Does it have any bugs or edge cases where it will not execute?
Describe the time complexity of the function and comment on its effectiveness.
Think of Stuff as tree and somestruff as rightchild and otherstuff as leftchild. Now problem is easy :)
- Abhishek June 22, 2012