There are two prerequisites for building a binary tree
[Prerequisite 1]
Build a binary tree based on the input (first | Middle | back) sequential traversal sequence (null values are replaced by #), such as AB # C # def.
[Prerequisite 2]
Build a binary tree based on any two input traversal sequences, such as abcedfg and ecbdfag.
There are two ways to build a binary tree
Method 1]
Recursion
Method 2]
Non-recursion
What you need to know
- Each node in the first sequence is actually the root node of its subtree.
- Each node in the central sequence divides the sequence into two parts: left and right. The sequence on the left of the node is the left subtree of the node, and the sequence on the right of the node is the right subtree of the node.
Some useful c Functions
- Strchr (const char * s, char C): locate the first occurrence of character C in string s