diff --git a/.gitignore b/.gitignore index 746ca57..048b31b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ /meghanadaFormatter.xml /out/ + +.dir-locals.el +/python/ +*.class diff --git a/BST.java b/BST.java index 3aa2dc8..75be4c6 100644 --- a/BST.java +++ b/BST.java @@ -31,8 +31,10 @@ public class BST { // search tree, keeping the tree ordered. public void add(String value) { BSTNode to_add = new BSTNode(value); - if (m_root == null) + if (m_root == null) { m_root = to_add; + m_size++; + } else { BSTNode current = m_root; BSTNode parent = null; @@ -45,7 +47,7 @@ public class BST { } else if (comparison < 0) { parent = current; - current = current.getRight(); + current = current.getLeft(); } else return; @@ -54,6 +56,7 @@ public class BST { parent.setRight(to_add); else parent.setLeft(to_add); + m_size++; } }