diff --git a/codes/cpp/chapter_tree/binary_tree_bfs.cpp b/codes/cpp/chapter_tree/binary_tree_bfs.cpp index ce0072b37..eeec2a18e 100644 --- a/codes/cpp/chapter_tree/binary_tree_bfs.cpp +++ b/codes/cpp/chapter_tree/binary_tree_bfs.cpp @@ -17,9 +17,9 @@ vector hierOrder(TreeNode* root) { TreeNode* node = queue.front(); queue.pop(); // 队列出队 vec.push_back(node->val); // 保存结点 - if (node->left != NULL) + if (node->left != nullptr) queue.push(node->left); // 左子结点入队 - if (node->right != NULL) + if (node->right != nullptr) queue.push(node->right); // 右子结点入队 } return vec; diff --git a/docs/chapter_tree/binary_tree.md b/docs/chapter_tree/binary_tree.md index 422b259e5..58034b18e 100644 --- a/docs/chapter_tree/binary_tree.md +++ b/docs/chapter_tree/binary_tree.md @@ -238,9 +238,9 @@ comments: true TreeNode* node = queue.front(); queue.pop(); // 队列出队 vec.push_back(node->val); // 保存结点 - if (node->left != NULL) + if (node->left != nullptr) queue.push(node->left); // 左子结点入队 - if (node->right != NULL) + if (node->right != nullptr) queue.push(node->right); // 右子结点入队 } return vec;