Binary Tree Iterator
My last homework assignment was to create an iterator for a binary tree. I had a bit of trouble figuring out how to use a stack in order to remember where the iterator has gone. I finally figured it out. It was quite enjoyable. I implemented it so that it traverses the tree pre-rder. I may, in my free time, go back and add functionality so that it will run in-order and post-order.

2 Comments:
If you are doing this in C, a few notes:
(0) Don't do it in C. C++ is slightly better, but there are far better languages out there for that kind of thing. I recommend Python.
(1) If you have to use C++, use the Standard Template Library. It brings C++ closer to a modern language.
All I've been using is Java. They don't teach much C or C++ at my school. Which is a problem when it comes to looking for internships.
I see you found my blog phil. I assume you came from Lem's. It was nice meeting you last weekend.
Post a Comment
<< Home