Definition Tree node (node): contains a data element and several branches pointing to the subtree;
Child node: node The root of the subtree of a point is called the child of the node;
P
Definition Tree node (node): contains a data element and several branches pointing to the subtree;
Child node: node The root of the subtree of a point is called the child of the node;
P
?
? ?
From
}??
Iterator
templatestruct __TreeIterator{ typedef BinTreeNode Node; typedef __TreeIterator Self; __TreeIterator() {} __TreeIterator(Node* node) :_node(node) {} Ref operator*() {assert( _node);
Because the recursion is achieved through the stack, although the recursive code sometimes looks simpler, then the recursion is too deep and it will be created p> Stack overflow. So we can achieve
Question request: Give two nodes in the binary tree arbitrarily, and find their nearest ancestor
There are three types Situation:
1. The binary tree is a search binary tree
If the
#include #include #include #include #define OK 1#define ERROR 0#define TRUE 1#define FALSE 0#define MAXSIZE 100 /* Initial allocation of storage space*/typedef int Status;typedef char TElemType; /*
1, construction
2, copy construction
3, destruction
4. depth
5, Number of leaves
6. Pre-order traversal recursive non-recursive
7, Middle-order traversal recursi
/* * 1. Recursive and non-recursive implementation of preorder traversal* 2. Intermediate traversal Recursive and non-recursive implementations of * 3. Recursive and non-recursive implementations o
The concept of binary tree, I don’t want to talk about it here, but you need to know the basics of full binary tree, complete binary tree, etc.
Concept, enter the topic below.
First cre
1. Create a node of the binary tree
#pragma once #include#includeusing namespace std;enum PointerTag{ THREND, LINK,};templatestruct BinaryTreeThdNode{ typedef BinaryTreeThdNode Node; BinaryTr