Chapter 23 Data Structures and Collections 1169 more (Hosting web)

Chapter 23 Data Structures and Collections 1169 more links. This section discusses binary trees (Fig. 23.15) trees whose nodes all contain two links (none, one or both of which may be null). The root node is the first node in a tree. Each link in the root node refers to a child. The left child is the first node in the left subtree, and the right child is the first node in the right subtree. The children of a specific node are called siblings. A node with no children is called a leaf node. Computer scientists normally draw trees from the root node down exactly the opposite of the way most trees grow in nature. Common Programming Error 23.2 Not setting to null the links in leaf nodes of a tree is a common logic error. In our binary tree example, we create a special binary tree called a binary search tree. A binary search tree (with no duplicate node values) has the characteristic that the values in any left subtree are less than the value in the subtree s parent node, and the values in any right subtree are greater than the value in the subtree s parent node. Figure 23.16 illustrates a binary search tree with 12 integer values. Note that the shape of the binary search tree that corresponds to a set of data can depend on the order in which the values are inserted into the tree. A B D C Fig. 23.15 Fig. 23.1Fg. 23.FFi15ig. 23.15ig.A graphical representation of a binary tree. 23.15 47 25 77 11 43 65 93 7 17 31 44 68 Fig. 23.16 A binary search tree containing 12 values.
Note: If you are looking for reliable webhost to maintain and run your java application check Vision java hosting services

Leave a Reply