Tips: Binary tree is a connected acyclic graph, and the degree of each node is 2 at most, which means that there are several direct children.
Balance factor (BF) : The depth of the left subtree of a node minus the depth of the right subtree. So depth and height, for a tree height and depth are the same, depth is accumulated from the root down, height is the opposite, height is accumulated from the leaf up, so for individual nodes, height and depth are not necessarily the same.
Existing array 35,28,16,44,56,78,12,96,21, constructing binary tree.
35 is the first element and becomes the root.
28 is less than 35, to the left of 35. 16 is less than 35, 16 is less than 28, to the left of 28. 44>35, 44 is to the right of 35. 56>44, to the right of 44. 78>56, to the right of 56. 12< 28,12 <16, to the left of 16. 96>78, to the right of 78. 21< 35,21 <28, 21>16, to the right of 16.Copy the code
Construct sorted binary tree with array 1,2,3,4,5.
1 is the first element, 1 is the root.
2>1, to the right of 1. 3 is bigger than 2. It's to the right of 2. 4>3, to the right of 3. 5>4, to the right of 4.Copy the code
Focus on the Java field, welcome your arrival ~ continue to update… ⛽ ️
This article is formatted using MDNICE
– END –