2. Chapter 9 tree -- Representation of the 9.2 tree

Source: Internet
Author: User

1. An array of Complete Binary Trees indicates 1. use an array to represent A Complete Binary Tree: store data from the root node, store the data in 0th locations as A, 1st and 2nd locations respectively, and store the L and G, respectively, from the left. 650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/14255R949-0.png "title =" Image.png "alt =" 162730493.png"/> 2. the reason for the convenience of Array Storage 1) the root node always appears at the position of array 0. 2) assuming that the position of a non-root node is in the I position of the array, its parent is always in the i-1)/2 position. For example, I = 3, the data is O, (3-1)/2 = 1, the location of the parent in the array is 1, and the data is L. 3) assume that the position of the data of a node in the array is I, then its child always appears in the following two locations left child at: 2 * I + 1 right child: 2 * I + 2 2. the node class of the Complete Binary Tree represents 1. each node of a binary tree can be considered as an object storage of a binary tree node class. The Node class contains private instance variables referenced to other nodes in the book. A complete tree represents a reference to the root node. 2. One Binary Tree: each node contains a private variable to store data and points to two references of its own left child and right child. Class BTNode <E> {private E data; private BTNode <E> left; private BTNode <E> right;...} 3. indicates the character binary tree, And the diagonal line indicates no reference. 650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/14255V633-1.png "title =" Image.png "alt =" 162833996.png"/>



There is no such thing as a great talent without great will-power. -- Balzac
Without great willpower, there will be no great talents. -- Balzac

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.