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

📄 binarysorttreedemo.java

📁 这是数据结构中的描述二叉树的一个JAVA 程序。
💻 JAVA
字号:
//实例化排序二叉树
package com.fluently.DataStructure.Applications;
import java.io.*;
import com.fluently.DataStructure.*;
public class  BinarySortTreeDemo 
{
	public static void main(String[] args) 
	{
		//建立一个二叉树
		BinarySortTree theBTree =new BinarySortTree();
		//插入结点,第一个接点是根接点
		BinaryTreeNode newNode=new BinaryTreeNode(23);
		theBTree.insertNode(newNode);
		newNode=new BinaryTreeNode(11);
		theBTree.insertNode(newNode);
		newNode=new BinaryTreeNode(6);
		theBTree.insertNode(newNode);
		newNode=new BinaryTreeNode(50);
		theBTree.insertNode(newNode);
		newNode=new BinaryTreeNode(29);
		theBTree.insertNode(newNode);
		newNode=new BinaryTreeNode(100);
		theBTree.insertNode(newNode);
		newNode=new BinaryTreeNode(60);
		theBTree.insertNode(newNode);
		newNode=new BinaryTreeNode(90);
		theBTree.insertNode(newNode);
		
		
		// 中序编历二叉树

		System.out.println("");
		System.out.println("中序编历如下:");
                                theBTree.inOrder(theBTree.root);
		//前序编历二叉树

		System.out.println("");
		System.out.println("前序遍历如下:");
		theBTree.proOrder(theBTree.root);
                                //后序遍历二叉树

		System.out.println("");
		System.out.println("后序遍历如下:");
		theBTree.postOrder(theBTree.root);

		//打印二叉树结点个数
        System.out.println("二叉树结点个数为:");
        System.out.println(theBTree.treeNodeCount());
		
		//打印二叉树深度
		System.out.println("二叉树深度为:");
        System.out.println(theBTree.treeHeight());
		//查找结点
            theBTree.find(60);
	
			
	}
}

⌨️ 快捷键说明

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