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

📄 demobasicbinarytreeuos.java

📁 国外的数据结构与算法分析用书
💻 JAVA
字号:
/* DemoBasicBinaryTreeUos.java
 * ---------------------------------------------
 * Copyright (c) 2002 University of Saskatchewan
 * All Rights Reserved
 * --------------------------------------------- */
package dslib.demo;

import dslib.tree.*;
import java.io.*;

 /** A class that demonstrates the use of any BasicBinaryTreeUos. */
public class DemoBasicBinaryTreeUos extends DemoSimpleTreeUos
{
	/**  A demo for testing BasicBinaryTreeUos. 
		@param t The tree that will be demo-ed.*/
	public DemoBasicBinaryTreeUos(BasicBinaryTreeUos t) 
	{	
		super(t);
		// place the output in a text file that reflects the class being demonstrated.
		String className = t.getClass().getName();
		className = className.substring(className.lastIndexOf(".")+1);
		PrintWriter out = null;
		try
		{
			out = new PrintWriter(new FileOutputStream("OutputDemo" + className + ".txt", true));
		} catch (Exception e)
		{
			System.err.println("Error creating output file in test routine for " + className);
			e.printStackTrace();
		}
		out.println("Demo for BasicBinaryTreeUos");
		out.println("Inserting 10....");
	        t.insertRoot(new Integer(10));
		out.println("Inserting 5....");
	        t.insertRootLeft(new Integer(5));
	   	out.println("Inserting 6....");     
	   	t.insertRootLeft(new Integer(6));
		out.println("Current Contents: " + t);
		out.println("Delete Root");
		t.deleteRoot();
		out.println("Current Contents: " + t);
		out.println("Inserting 7....");
	        t.insertRootRight(new Integer(7));
		out.println("Inserting 12....");
	        t.insertRootRight(new Integer(12));
		out.println("Inserting 14....");
	        t.insertRootRight(new Integer(14));
		out.println("Inserting 21....");
	        t.insertRootRight(new Integer(21));
		out.println("Inserting 10....");
	        t.insertRootLeft(new Integer(10));
		out.println("Inserting 5....");
	        t.insertRootLeft(new Integer(5));
		out.println("Current Contents: " + t);
		out.println("Delete Root");
		t.deleteRoot();
		out.println("Current Contents: " + t);
		out.println("Delete Root");
		t.deleteRoot();
		out.println("Current Contents: " + t);
		out.println("Delete Root");
		t.deleteRoot();
		out.println("Current Contents: " + t);
		out.println("Is full? " + t.isFull());
		out.println("is empty? " + t.isEmpty());
		out.println("Apperance of tree:");
		out.println(t.toStringByLevel()); 
		out.println("Wipe Out");
		t.wipeOut();		
		out.close();
	}
}

⌨️ 快捷键说明

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