mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-07 06:44:57 +08:00
Format the Java codes with the Reat Hat extension.
This commit is contained in:
@ -15,7 +15,8 @@ public class binary_tree_dfs {
|
||||
|
||||
/* 前序遍历 */
|
||||
static void preOrder(TreeNode root) {
|
||||
if (root == null) return;
|
||||
if (root == null)
|
||||
return;
|
||||
// 访问优先级:根节点 -> 左子树 -> 右子树
|
||||
list.add(root.val);
|
||||
preOrder(root.left);
|
||||
@ -24,7 +25,8 @@ public class binary_tree_dfs {
|
||||
|
||||
/* 中序遍历 */
|
||||
static void inOrder(TreeNode root) {
|
||||
if (root == null) return;
|
||||
if (root == null)
|
||||
return;
|
||||
// 访问优先级:左子树 -> 根节点 -> 右子树
|
||||
inOrder(root.left);
|
||||
list.add(root.val);
|
||||
@ -33,7 +35,8 @@ public class binary_tree_dfs {
|
||||
|
||||
/* 后序遍历 */
|
||||
static void postOrder(TreeNode root) {
|
||||
if (root == null) return;
|
||||
if (root == null)
|
||||
return;
|
||||
// 访问优先级:左子树 -> 右子树 -> 根节点
|
||||
postOrder(root.left);
|
||||
postOrder(root.right);
|
||||
|
Reference in New Issue
Block a user