/**
* Created by 码上风云 on 2020/10/7.
*/
class Node<T> {
public Node left, right;
public T data;
//创建空节点
public Node() {
data = null;
left = null;
right = null;
}
//创建一个二叉树结点
public Node(T x) {
this.data = x;
left = null;
right = null;
}
}
public class Tree<T> {
public Node<T> root;
public Tree(Node root) {
this.root = root;
}
//创建一颗空二叉树
public Tree() {
this.root = new Node<T>();
}
//生产一颗二叉树
public Tree(T x) {
this.root = new Node<T>(x);
}
//插入左节点
public boolean insertLeft(T x, Node<T> parent) {
if (parent == null) {
return false;
}
Node<T> p = new Node<T>(x);
if (parent.left == null) {
parent.left = p;