On Friday 04 July 2003 12:37 pm, Jerry Feldman wrote:
On Fri, 4 Jul 2003 12:32:16 -0700
"Steven T. Hatton" <hattons@globalsymmetry.com> wrote:
in a given language, my next self-inflicted pedagogical exarcise is to write some kind of recursive data structure representation of a binary tree.
The simple version of the data structure is something like:
struct Node { char * data; Node * left_child; Node * right_child; };
A few years ago as an exercise, I wrote a template version of an AVL tree (eg. a self balancing binary tree). In my tree there are 2 classes: The outer class, avltree, and an inner node.
I think the STL provides a very good basic set of useful data structures, but they may not be sufficient for some uses.
I have to confess, without the ability to do some kind of recursion, I don't see where I would have much use for such a library. It looks as though there may be a solution. I am just now looking this over. This looks like a fantastic course: http://www.cs.uiowa.edu/~rlawrenc/teaching/030/Notes/
My implementation did not have iterators, and I'm not sure how I would implement an iterator in a binary tree.
I guess one could do some kind of infix, prefix or postfix traversal, or simply iterate over the children. In the case of a binary tree, that doesn't make a lot of sense. In the case of an N-ary(sic) tree, that may make more sense. Steven