Merge pull request #4644 from bi-/master
Delete the root element from the tree.
This commit is contained in:
commit
89d48625f9
|
@ -57,7 +57,7 @@ public class BinaryTree {
|
|||
}
|
||||
|
||||
public void delete(int value) {
|
||||
deleteRecursive(root, value);
|
||||
root = deleteRecursive(root, value);
|
||||
}
|
||||
|
||||
private Node deleteRecursive(Node current, int value) {
|
||||
|
|
|
@ -6,7 +6,7 @@ import static org.junit.Assert.assertTrue;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
public class BinaryTreeTest {
|
||||
public class BinaryTreeUnitTest {
|
||||
|
||||
@Test
|
||||
public void givenABinaryTree_WhenAddingElements_ThenTreeNotEmpty() {
|
||||
|
@ -70,6 +70,17 @@ public class BinaryTreeTest {
|
|||
assertEquals(initialSize, bt.getSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void it_deletes_the_root() {
|
||||
int value = 12;
|
||||
BinaryTree bt = new BinaryTree();
|
||||
bt.add(value);
|
||||
|
||||
assertTrue(bt.containsNode(value));
|
||||
bt.delete(value);
|
||||
assertFalse(bt.containsNode(value));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenABinaryTree_WhenTraversingInOrder_ThenPrintValues() {
|
||||
|
|
@ -6,7 +6,7 @@ import org.junit.jupiter.api.Assertions;
|
|||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class TrieTest {
|
||||
public class TrieUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenEmptyTrie_thenNoElements() {
|
Loading…
Reference in New Issue