代码拉取完成,页面将自动刷新
package week6;
import week2.EmptyCollectionException;
import java.util.Iterator;
public class LinkedBinaryTreeTest {
public static void main(String[] args) throws EmptyCollectionException {
LinkedBinaryTree num1 = new LinkedBinaryTree("January");
LinkedBinaryTree num3 = new LinkedBinaryTree("February");
LinkedBinaryTree num4 = new LinkedBinaryTree("May");
LinkedBinaryTree num5 = new LinkedBinaryTree("July");
LinkedBinaryTree num6 = new LinkedBinaryTree("June", num3, num1);
LinkedBinaryTree num7 = new LinkedBinaryTree("September", num4, num5);
LinkedBinaryTree num2 = new LinkedBinaryTree("Octomber", num6, num7);
Iterator a;
System.out.println("前序遍历结果为: ");
a = num2.iteratorPreOrder();
while (a.hasNext())
System.out.print(a.next() + " ");
System.out.println("中序遍历结果为: ");
a = num2.iteratorInOrder();
while (a.hasNext())
System.out.print(a.next() + " ");
System.out.println("后序遍历结果为: ");
a = num2.iteratorPostOrder();
while (a.hasNext())
System.out.print(a.next() + " ");
System.out.println("层序遍历结果为: ");
a = num2.iteratorLevelOrder();
while (a.hasNext())
System.out.print(a.next() + " ");
System.out.println("树的大小是: " + num2.size());
System.out.println("树为空吗?: " + num2.isEmpty());
System.out.println("输出树: ");
num2.oString();
System.out.println( "是否含有May:" + num2.contains("May"));
num2.removeRightSubtree();
System.out.println();
num2.oString();
num2.removeAllElements();
num2.oString();
System.out.println("num3是否是叶子:" + num1.root.judge());
System.out.println("num5是否是叶子:" + num6.root.judge());
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。