I know that there is such a way. The search for a solution is performed using 2 (seemingly) lists. But I hardly found any info in google. The tree is not binary, but hexahedral, so to speak. But I think this algorithm will work in any.

  • This is called “k-tree with k = 6” =). - kirelagin

2 answers 2

Well, do the usual non-recursive detour in depth, as in any book on graph theory are taught.
Two lists - this, of course, bust, but the stack is useful.

Or did I not catch something?

  • Stack - for search in depth, turn - in width. - VladD

The first link from the handicraft of Seregi Brin! http://pco.iis.nsk.su/ICP/Practice/dd8-3/node7.html

  • Are you sure you wanted to make the answer general? - VladD
  • And what is the difference from not common? And how to subscribe to add comments to the topic? - Evgeny Veprikov
  • The general answer is not the author, but the collective one. Points for him you do not go. It is used if you do not write yourself, but collect other people's information so that you will not drip into an undeserved reputation. In the case of your answer, this is apparently not the case. - VladD
  • In theory, you automatically receive comments (1) on your answer, and (2) those where you are mentioned like this: @ЕвгенийВеприков . Notifications are delivered to the internal inbox, the red one at the top of the page. You can subscribe to receive by mail every X hours. - VladD
  • @YevgeniyVeprikov, before answering, I recommend looking at the date of the question (and then, decide for yourself ...) - avp