二叉树的遍历(前序、中序、后序)*(递归、非递归)共6种
本文最后更新于 2025年4月21日 上午
二叉树结构定义
1 | struct Node |
递归版
中序遍历(左、根、右)
1 | void BinarySearchTree::inOrder(Node *p) |
前序遍历(根、左、右)
1 | void BinarySearchTree::preOrder(Node *p) |
后序遍历(左、右、根)
1 | void BinarySearchTree::postOrder(Node *p) |
非递归版
中序遍历(左、根、右)
1 | void BinarySearchTree::nonRecursiveInOrder() |
前序遍历(根、左、右)
1 | void BinarySearchTree::nonRecursivePreOrder() |
后序遍历(左、右、根)
1 | void BinarySearchTree::nonRecursivePostOrder() |
二叉树的遍历(前序、中序、后序)*(递归、非递归)共6种
http://example.com/2020/09/19/二叉树的遍历(前序、中序、后序)(递归、非递/