public class BTPrinter extends Object
| Constructor and Description |
|---|
BTPrinter() |
| Modifier and Type | Method and Description |
|---|---|
static void |
printRandomBST(int n,
int bound)
Print a random binary search tree.
|
static void |
printTree(Object... objs)
Print a tree from a leetcode-style level order array.
|
static void |
printTree(String s)
Print a tree from a leetcode-style level order expression.
'#' means a path terminator where no node exists below.
|
static void |
printTreeLevelOrder(Object... objs)
Print a tree from a typical level order array.
|
static void |
printTreeLevelOrder(String s)
Print a tree from a typical level order expression.
'#' means null.
|
public static void printTree(String s)
For example, if the input string is "1,#,2,3", you'll get the output below:
1 \ 2 / 3
What's leetcode-style level order expression?
See: - https://support.leetcode.com/hc/en-us/articles/360011883654-What-does-1-null-2-3-mean-in-binary-tree-representation
s - the string value to be parsed.public static void printTreeLevelOrder(String s)
For example, if the input string is "1,#,2,#,#,3", you'll get the output below:
1 \ 2 / 3
s - the string value to be parsed.public static void printTree(Object... objs)
What's leetcode-style level order array?
See: - https://support.leetcode.com/hc/en-us/articles/360011883654-What-does-1-null-2-3-mean-in-binary-tree-representation
objs - the objects you want to print.
Notice that you can input instances with different types at the same time, the algorithm will always work.
The value of each tree node will equal to the String value of the corresponding obj, i.e. String.valueOf(obj).
A null object means a path terminator where no node exists below.public static void printTreeLevelOrder(Object... objs)
objs - the objects you want to print.
Notice that you can input instances of different Classes at the same time, the algorithm will always work.
The value of each tree node will equal to the String value of the corresponding obj, i.e. String.valueOf(obj).public static void printRandomBST(int n,
int bound)
n - the node count of the BST, must be a positive integer, cannot be larger than bound.bound - bound of the val of a tree node, must be a positive integer, cannot be smaller than n.Copyright © 2019. All rights reserved.