What can I improve on this Algorithm?

closed account (D4S8vCM9)
I published an article in the articles section, but got a quite low vote on it.
http://www.cplusplus.com/articles/4wTbqMoL/

So; i would like to discuss what can I improve on my algorithm, since it is also an integral part of my project HGL.
Personally, I'm not really seeing a point to it. If I have to write the functors your function takes then it isn't saving me much time or code. So I might as well write an iterator and traversal functions myself.
closed account (D4S8vCM9)
Ok, now I understand the point of critisism, it seems people are annoyed by the sourrounding "body".
My question was the "Algorithm", i.e. the traversal.

I spend hours to search for an NON recursive algorithm on n-trees. No problem to find for binary trees, but not for n-ary trees, in the case of HGL - my project - rather complex compositions.

A "naive" recursive implementation would lead with guarantee earlier or later to stack overflows or at least to an inacceptable performance.

In my case I took the the ideas from the great book "Algorithms" by R. Sedgewick, where he spends some lines on how to remove recusrsion from arbitrary functions.

I implemented the "naive" algorithm first and succesively removed the recursion according his scheme and finally improved it to a "readable" source. His scheme leads to code with an horrible amount of "gotos" in it. This is wanted by him and he notes after testing, the next step is too change all gotos to ordinary loops.

I.e. the "traversal" itself is the point. About the "body" I'm willing to try out every suggestion, but my question was about the algorithm itself.

EDIT: BTW: HGL has a iterator on top of it, but it is too specialized to include into the article.
Last edited on
Topic archived. No new replies allowed.