# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
(A) a binary tree preorder
Recursion:
Note:
1. Self-calling class method
2. Python in the list can be directly obtained by adding a new list:
Iteration:
Preorder (b) a binary tree (preamble) traversal
Recursion:
Iteration:
After the sequence (iii) the binary tree traversal
Recursion:
Has been explained in detail, it will not be described.
Iteration 1:
Iteration 2:
(Iv) the level of binary tree traversal
Structure cohort