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

Php - Delimiter must not be alphanumeric or backslash -

Delphi interface implements -

java - How to create Table using Apache PDFBox -