Introduction
It is easy level tree algorithm. But I had a lot of fun to write the code since I failed the first time. I used Stack instead of Queue to do level order tree traversal. There is a problem since stack will not maintain first in first out order. The node visited is wrong.
My static analysis of the algorithm went wrong. It just reminded me that I need more careful to choose a data structure when I design the algorithm.
My practice
Here is my C# code.
No comments:
Post a Comment