ctci icon indicating copy to clipboard operation
ctci copied to clipboard

4.8 Java

Open birdyhuang opened this issue 9 years ago • 5 comments

The question said both trees are very large. Does it mean we should not use a recursive way of doing this?

birdyhuang avatar Feb 28 '16 23:02 birdyhuang

Complexity will remain same in case of recursion.

piyush121 avatar Feb 28 '16 23:02 piyush121

But recursion may get stack overflow, doesn't it?

birdyhuang avatar Feb 28 '16 23:02 birdyhuang

Yeah it will. But I think we have to assume that our system can handle O(n) space.

piyush121 avatar Feb 28 '16 23:02 piyush121

For what it's worth, I didn't use recursion for my solution precisely because it mentioned the trees are large.

futuremojo avatar Feb 28 '16 23:02 futuremojo

Then why does the question mention the size of the tree? Is it just useless or some kinda clue?

birdyhuang avatar Feb 28 '16 23:02 birdyhuang