Traverse tree without recursion and stack in C

后端 未结 5 1226
日久生厌
日久生厌 2021-02-05 21:38

How to traverse each node of a tree efficiently without recursion in C (no C++)?

Suppose I have the following node structure of that tree:

struct Node
{
         


        
5条回答
  •  灰色年华
    2021-02-05 22:22

    You can use the Pointer Reversal method. The downside is that you need to save some information inside the node, so it can't be used on a const data structure.

提交回复
热议问题