@@ -52,12 +52,12 @@ With the methods `add` and `remove`, we have to guarantee that our tree always h
5252===== Inserting new elements in a BST
5353
5454.For inserting an element in a BST, we have two scenarios:
55- 1. If the tree is empty (root element is null), we add the newly created node as root, and that's it!
56- 2. If the tree has a root, compare the new value with the root. Then we have three possibilities:
57- 2.1 . `root == newValue`: we increase the duplicity counter in that case, and done!
58- 2.2 `root > newValue`, we search on the left side of the root.
59- 2.3 `root < newValue`, we search on the right side of the root.
60- 3. Repeat the comparison between the current node and `newValue`, until we find the value or (null) space.
55+ . If the tree is empty (root element is null), we add the newly created node as root, and that's it!
56+ . If the tree has a root, compare the new value with the root. Then we have three possibilities:
57+ . . `root == newValue`: we increase the duplicity counter in that case, and done!
58+ .. `root > newValue`, we search on the left side of the root.
59+ .. `root < newValue`, we search on the right side of the root.
60+ . Repeat the comparison between the current node and `newValue`, until we find the value or (null) space.
6161
6262For instance, let’s say that we want to insert the values 19, 21, 10, 2, 18 in a BST:
6363
0 commit comments