We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d150991 commit 132528dCopy full SHA for 132528d
java2/dsa/trees/bst/BstInsert.java
@@ -8,7 +8,7 @@ public class BstInsert {
8
public static void insert(BinaryNode parent, BinaryNode node, int value) {
9
if (node == null) {
10
BinaryNode newNode = new BinaryNode(value);
11
- if (value < parent.value) {
+ if (value <= parent.value) {
12
parent.left = newNode;
13
} else {
14
parent.right = newNode;
@@ -31,6 +31,7 @@ public static void main(String[] args) {
31
BinaryNode bst = DataSample.getExampleBinarySearchTree();
32
BstInsert.add(bst, 17);
33
BstInsert.add(bst, 18);
34
+ BstInsert.add(bst, 18);
35
BstInsert.add(bst, 100);
36
BstInsert.add(bst, 28);
37
}
0 commit comments