/*
* 先序创建二叉树
* 返回:根节点
*/
public TreeNode<T> creatBinaryPre(LinkedList<T> treeData)
{
TreeNode<T> root=null;
T data=treeData.removeFirst();
if (data!=null)
{
root=new TreeNode<T>(data, null, null);
root.left=creatBinaryPre(treeData);
root.right=creatBinaryPre(treeData);
}
return root;
}
* 先序创建二叉树
* 返回:根节点
*/
public TreeNode<T> creatBinaryPre(LinkedList<T> treeData)
{
TreeNode<T> root=null;
T data=treeData.removeFirst();
if (data!=null)
{
root=new TreeNode<T>(data, null, null);
root.left=creatBinaryPre(treeData);
root.right=creatBinaryPre(treeData);
}
return root;
}