4 ms·
The "complex one" is better because it is correct. I don't know C#, but as I read your program, I'm pretty sure it's wrong. It seems like you just do a depth f
by jonsen 12y ago
The "complex one" is better because it is correct.
I don't know C#, but as I read your program, I'm pretty sure it's wrong.
It seems like you just do a depth first traversal. That way you can't get breadth first numbering all the way through without further "complexity".
It's pure luck, that you get his small tree right. Try a bigger tree.
- mdpopescu 12y agoI did try a bigger tree, it's still working correctly. (If it had been a depth-first search it would have been incorrect on that tree too - I know because I did write a depth-first search at first.)