- add dependency
<dependency>
<groupId>io.github.light0x00</groupId>
<artifactId>binary-tree-printer</artifactId>
<version>0.0.2</version>
</dependency>
- implement
IPrintableBinaryTreeNode
@AllArgsConstructor
class BinaryTreeNode implements IPrintableBinaryTreeNode {
//...
}
- construct your tree structure then print it
BinaryTreeNode tree=buildTree();
BinaryTreePrinter.print(tree);
it will output the tree as ascii format:
1
/ \
/ \
/ \
/ \
2 33
/ \ / \
/ \ / \
4 4 6 7