C++ general tree iterator - backward paths -


i'd define iterator on general tree. here example(from wikipedia) of binary one:

iterator should allow me traverse tree structure in pre-order. can achieve using std::stack (get node stack, set current one, add it's children stack).

but wish nodes, on "backward".

nodes @ example picture should visited in following order: f, b, a, b*, d, c, d*, e, d*, b*, f*, g, i, h

'*' - means node visited in backward.

iterator should store information if "normal" visit, or backward one.

which approach take handle that?


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -