Chapter 23 Data Structures and Collections 1171 30
Chapter 23 Data Structures and Collections 1171 30 set 31 { 32 leftNode = value; 33 } 34 } 35 36 // Data property 37 public int Data 38 { 39 get 40 { 41 return data; 42 } 43 44 set 45 { 46 data = value; 47 } 48 } 49 50 // RightNode property 51 public TreeNode RightNode 52 { 53 get 54 { 55 return rightNode; 56 } 57 58 set 59 { 60 rightNode = value; 61 } 62 } 63 64 65 // insert TreeNode into Tree that contains nodes; 66 // ignore duplicate values 67 public void Insert( int insertValue ) 68 { 69 // insert in left subtree 70 if ( insertValue < data ) 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 Fig. 23.17 Fig. 23.1FiFig. 23.17g. 23.17 Fig. 23.17 Definitions of TreeNodeand Treefor a binary search tree. (Part 2 of 5.)
Note: In case you are looking for affordable and reliable webhost to host and run your business application check Vision php5 hosting services