⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testexampletree.java

📁 国外的数据结构与算法分析用书
💻 JAVA
字号:
import dslib.tree.*;

public class TestExampleTree
{
	ExampleTree t;

	public TestExampleTree()
	{
		t = new ExampleTree();
		makeTree();
		System.out.println("The height of the tree is " + t.height());
		System.out.println("The size (# of nodes) of the tree is " + t.size());
		System.out.println("The number of leaves in the tree is " + t.numberOfLeaves());
		System.out.println("The sum of the values in the tree is " + t.sum());
		System.out.println("The height &  max imbalance of the current tree " + t.maxImbal());
		System.out.println("The max Imbal Ineff of tree is " + t.maxImbalIneff());
	}

	/**	Create the expression tree for 2*a+b*c
		Analysis: Time = (1) */	
	public void makeTree()
	{
		ExampleTree t1, t2, t3, t4, t5, t6;
		t1 = new ExampleTree(null, new Integer(2), null); 
		t2 = new ExampleTree(null, new Integer(7), null); 
		t3 = new ExampleTree(t1, new Integer(4), t2); 
		t5 = new ExampleTree(null, new Integer(9), null); 
		t6 = new ExampleTree(null, new Integer(1), null);
		t4 = new ExampleTree(t5, new Integer(5), t6);
		t = new ExampleTree(t3, new Integer(8), t4);
	
		System.out.println(t.toString());
	}

	public static void main(String args[])
	{
		TestExampleTree c = new TestExampleTree();
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -