Iteration is impossible iterative
1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x), left(NULL), right(NULL) {} 8 * }; 9 */ 10 class Solution { 11 public: 12 bool flag = true; //判断标志 13 bool isSymmetric(TreeNode* root) { 14 if (!root) return 1; 15 DFS (directory root-> left, directory root-> right); 16 return In Flag; . 17 } 18 is void DFS (L * the TreeNode, the TreeNode * R & lt) { . 19 IF (R & lt In Flag || L &&!!!) Return ; / / prune 20 is the else IF (L-L || R & lt ||> Val = the R-> Val!!!) { // Analyzing asymmetric 21 is In Flag = to false ; 22 is return ; 23 is } 24 DFS (L-> left, the R-> right); // symmetrical search comparator 25 DFS (L-> right, the R->left); 26 } 27 };