Data Structure tutorial (Java description) edited by Xu xiaokai-review abstract 05

Source: Internet
Author: User

Data Structure tutorial (Java description) edited by Xu xiaokai-review abstract 05

Chapter 5 tree and binary tree

The nature of the tree:

1. The number of knots in the tree is equal to the number of all knots plus 1.

2. In the tree with a K Degree, at most K ^ (I-1) knots (I> = 1) on the I layer ).

3. K-tree H depth has at most (K ^ h-1)/(k-1) nodes.

4. The minimum depth of K-tree with N nodes is...

Binary Tree nature

1. The number of terminal knots on a binary tree is equal to the number of dual-branch knots plus 1.

2. Binary Tree on the I layer at most 2 ^ (I-1) nodes (I> = 1 ).

3. A binary tree with a depth of H has at most 2 ^ (h-1) nodes.

4. The depth of the Complete Binary Tree with N nodes is...

 

Link storage structure of Binary Trees

Node Type Definition

public class BTreeNode{Object element;BTreeNode left,right;public BTreeNode(Object obj) {element = obj;left =right=null;}public BTreeNode(Object obj,BTreeNode lt,BTreeNode rt){element = obj;left = lt;right = rt;}}

Binary Tree for Link Storage

 
Public class linkbinarytree implements binarytree {protected btreenode root; // defines the root pointer (reference) of the inherited Binary Tree public linkbinarytree () {root = NULL ;} // operate public btreenode getroot () {return root ;}...}

A queue is required for hierarchical traversal.

Implementation of link Storage Class of Binary Search Tree

 

public class linkBinarySearchTree extends linkBinaryTree implements BinarySearchTree{public linkBinarySearchTree(){super();}public Object find(final Object obj){}public Object update(final Object obj){}public boolean insert(final Object obj){}public boolean delete(final Object obj){}} 

The heap is divided into a large heap and a small heap.

 

Public class sequenceheap implements heap {final int maxsize = 10; // array initial length private object [] heaparray; // array declaration private int length; // actual length of the current heap // Operation Public sequenceheap () {length = 0; heaparray = new object [maxsize];} public sequenceheap (int n) {}....}

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.