Web hosting domains - 1180 Data Structures and Collections Chapter 23 56

1180 Data Structures and Collections Chapter 23 56 return rightNode; 57 } 58 59 set 60 { 61 rightNode = value; 62 } 63 } 64 65 // insert TreeNode into Tree that contains nodes; 66 // ignore duplicate values 67 public void Insert( IComparable insertValue ) 68 { 69 // insert in left subtree 70 if ( insertValue.CompareTo( data ) < 0 ) 71 { 72 // insert new TreeNode 73 if ( leftNode == null ) 74 leftNode = new TreeNode( insertValue ); 75 76 // continue traversing left subtree 77 else 78 leftNode.Insert( insertValue ); 79 } 80 81 // insert in right subtree 82 else if ( insertValue.CompareTo( data ) > 0 ) 83 { 84 // insert new TreeNode 85 if ( rightNode == null ) 86 rightNode = new TreeNode( insertValue ); 87 88 // continue traversing right subtree 89 else 90 rightNode.Insert( insertValue ); 91 } 92 93 } // end method Insert 94 95 } // end class TreeNode 96 97 // class Tree definition 98 public class Tree 99 { 100 private TreeNode root; 101 102 // construct an empty Tree of integers 103 public Tree() 104 { 105 root = null; 106 } 107 Fig. 23.20 Fig. 23.2FiFig. 23.20g. 23.20Definitions of class TreeNodeand Treefor manipulating Fig. 23.20 IComparableobjects. (Part 3 of 5.)
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision j2ee hosting services

Leave a Reply