The data structure can be classified into two types: linear structure and nonlinear structure, the content of this paper is about nonlinear structure: The basic definition of tree and its related algorithm. Some basic conceptual definitions of trees are available for referen
Rotate the 90-degree output binary tree counterclockwise (Data Structure Test 2) and the 90-degree Binary Tree
Rotating a 90-degree print binary tree in a counter-clockwise manner is a special medium-order traversal algorithm.
Rotate 90 degrees counter-clockwise
The implementation is also very simple, similar to t
Label:Atitit. various data types( tree structure , table-shaped data ) the structure and storage database Attilax Summary1. Data structure (tree structure, table shape data, object structure
Sub-structure and sub-structure of the tree
1. Question
Enter Two Binary Trees A and B to determine whether B is A sub-structure. The binary tree structure is as follows:
Struct BinaryTreeNode
{
Int m_nValue;
BinaryTreeNode * m_pL
A tree is a finite set of n (n>=0) data elements of the same type. The data element in the tree is called a node. The n=0 tree is called the empty tree, and any non-empty tree T for N>0 is:1. There is only one special node called the root node of the
1, the formal definition of the tree:A tree is a finite set of T, consisting of one or more nodes, which has a specific node called the root, and the remaining nodes can be divided into m (m≥0) disjoint finite set t1,t2,t3,..., Tm, each set is itself a tree, and is called the root subtree.2, the basic terms of the tree:1. Node: An element in a
node can contain up to 2 T-1 keywords, so an internal node can have up to 2 t children. Let's say that a node is full, if it happens to have 2 T-1 keywords.
T = 2, B is the simplest. At this time, each inner node has two, three, or four children, that is, a 2-3-4 tree. However, in practice, a large T is usually used.
Purpose:
Tree B is a multi-channel balanced search
The pre-order traversal order of the binary tree is: root node, left Tree, right tree
The central traversal order is: left Tree, root node, right tree
The descending order of traversal is: left Tree, right
Data Structure-tree, Data Structure
1. Tree Definition
A tree is a finite set of n (n> = 0) nodes. N = 0 is called an empty tree. In any non-empty tree: 1. There is only one specific ro
root node's right subtree (left), resulting in the root node's balance factor from-1 to-2 Zuozi
The imbalances that may result from the four situations can be balanced by the rotation. There are two basic types of rotation:
(1) Left rotation: Rotate the root node to (the root node) the left child position of the right child
(2) Right rotation: Rotate the root node to (the root node) the right child's position on the left child
3. The rotation operation of AVL
Implementation of Binary Tree in Java interview book
Author: Egg
Email: xtfggef@gmail.com
Weibo: http://weibo.com/xtfggef
Blog: http://blog.csdn.net/zhangerqing (reprinted please explain the source)
We will continue to explain the data structure in the previous article. This chapter describes the data structure tree an
Sequential storage structureThe type definition of a binary tree storage structure:#defineMAX_SIZE typedeftelemtypesqbitree[MAX_SIZE];The data elements of a complete binary tree are stored in a contiguous set of storage units, "top-down, from left to right".The node element numbered I on a complete binary tree is stor
traverses the right sub-tree.Implement template Traversal algorithm for post (root) Order:1. If the binary tree is empty tree, then empty operation;2. otherwise(1) to traverse the left subtree;(2) to traverse the right sub-tree;(3) Access to the root node.Implement template Hierarchical traversal algorithm and visit operation:Template Template Binary
Data Structure Arrangement (2) tree and Data Structure ArrangementI. Preface
For project source code and other statements, see data structure (1) linear structure.
Ii. Related Concepts
As a one-to-multiple nonlinear data structure
9.1Overview
1) tree is a data storage structure
2 The tree combines the advantages of an ordered array and a linked list, and avoids the drawbacks of ordered arrays and linked lists.
3 ) Tree Term: path, root, parent node, child node, leaf node, layer, subtree, access, tr
"left child, that is K1" shaking vigorously. The K1 becomes the root node, K2 becomes the right subtree of K1, and the right subtree of K1 becomes the K2 left subtree.The rotation of the LR?? When LR is out of balance, it takes two rotations to restore the AVL tree to a balanced position. Such as:?? The first rotation is "RR rotation" around "K1", and the second is "ll rotation" around "K3". Copyright NOTICE: This article for Bo Master original artic
Title DescriptionEnter two binary trees, a, B, to determine whether a is a sub-structure of a. (PS: We agree that an empty tree is not a sub-structure of any tree)Title Addresshttps://www.nowcoder.com/practice/6e196c44c7004d15b1610b9afca8bd88?tpId=13tqId=11170rp=3ru=/ta/ Coding-interviewsqru=/ta/coding-interviews/quest
Binary tree One of data structure experiments: isomorphism of treesTime limit:1000ms Memory limit:65536kb Submit Statisticproblem DescriptionGiven two trees T1 and T2. If T1 can be converted to T2 by several times or so, we call the two trees "isomorphic". Example 1 gives the two trees is isomorphic, because we put one of the nodes of a tree, a, B, g of the child
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.