Non-recursive algorithm for traversing a binary tree is not difficult

The relevant knowledge mentioned in the article is located in the column: "Data Structure and Course Design"

Preface

This article will introduce in detail the non-recursive traversal algorithm of chained storage binary trees. There are three types, namely pre-order, in-order and post-order. And use these traversal algorithms and add some extensions to complete classic problems, such as finding the height of a tree, traversing in reverse order, etc.

1. Review of recursive algorithms

A brief review of the recursive traversal method of chained storage binary trees:
the code for the binary tree storage structure is given:

typedef struct 

Guess you like

Origin blog.csdn.net/m0_58618795/article/details/132128417