class TreeNode {
String value;
TreeNode left;
TreeNode right;
public TreeNode(String value){ //constructs a leaf
this.value = value;
right = null;
left = null;
}
public TreeNode(String value, TreeNode left, TreeNode right){
this.value = value;
this.left = left;
this.right = right;
}//makes treenode with left and right children
public TreeNode getLeft(){
return this.left;
}
public TreeNode getRight(){
return this.right;
}
public boolean isLeaf(){
if (this.right == null && this.left == null){
return true;
}
else{
return false;
}
}
}
class Main{
public static TreeNode maketree(){
//create Binary Tree with traversal
}
public static void main(String[] args){
String Classical = "Do you like classical music?";
String Mozart = "Are you a fan of Mozart?";
String TakeFive = "\"Take Five\" by Dave Brubeck.";
String EineKleine = "Eine Kleine Nachtmusik.";
String ThreeRomances = "\"3 Romances\" by Clara Schumann.";
String[] pre = {Classical, Mozart, EineKleine, ThreeRomances, TakeFive};
}
}
数组 pre 已经在 pre order 我希望将它转换回二叉树任何带有“?”的字符串 是一个以经典为根的节点,任何带有 '.' 的节点。是一片叶子。我发现很多整数,但我看不到字符串。