Add implementation of array binary tree.

Rewrite the tree serialization and deserialization methods.
Add applications of array and linked list.
This commit is contained in:
krahets
2023-07-19 16:09:27 +08:00
parent c68f18e480
commit 4e13755023
26 changed files with 680 additions and 178 deletions

View File

@@ -59,15 +59,4 @@ public class TreeNode {
}
return list;
}
/* Get a tree node with specific value in a binary tree */
public static TreeNode? GetTreeNode(TreeNode? root, int val) {
if (root == null)
return null;
if (root.val == val)
return root;
TreeNode? left = GetTreeNode(root.left, val);
TreeNode? right = GetTreeNode(root.right, val);
return left ?? right;
}
}