Site Search:

EdgeFindOneTest.java


import org.junit.Test;

public class EdgeFindOneTest {
    @Test
    public void basicTest() {
        int[] values = {10, -5, -20};
        System.out.println("Layer order");
        BTree root = EdgeFindOne.buildTree(values);
        BTreePrinter.printNode(root);
        int k = 15;
        System.out.println("the first node with value above " + k);
        System.out.println(EdgeFindOne.largerThan(root, k));
        k = 6;
        System.out.println("the first node with value above " + k);
        System.out.println(EdgeFindOne.largerThan(root, k));
        
        int[] values2 = {10, -5, 20};
        System.out.println("Layer order");
        root = EdgeFindOne.buildTree(values2);
        BTreePrinter.printNode(root);
        k = 6;
        System.out.println("the first node with value above " + k);
        System.out.println(EdgeFindOne.largerThan(root, k));
        
        int[] values3 = {10, 9, 14, -5, -20, 3, -15, 7, 26, -9};
        System.out.println("Layer order");
        root = EdgeFindOne.buildTree(values3);
        BTreePrinter.printNode(root);
        k = 6;
        System.out.println("the first node with value above " + k);
        System.out.println(EdgeFindOne.largerThan(root, k));
        
        int[] values4 = {10};
        System.out.println("Layer order");
        root = EdgeFindOne.buildTree(values4);
        BTreePrinter.printNode(root);
        k = 6;
        System.out.println("the first node with value above " + k);
        System.out.println(EdgeFindOne.largerThan(root, k));
        
        int[] values5 = {};
        System.out.println("Layer order");
        root = EdgeFindOne.buildTree(values5);
        BTreePrinter.printNode(root);
        k = 6;
        System.out.println("the first node with value above " + k);
        System.out.println(EdgeFindOne.largerThan(root, k));
        
        int[] values6 = {-1};
        System.out.println("Layer order");
        root = EdgeFindOne.buildTree(values6);
        BTreePrinter.printNode(root);
        k = 6;
        System.out.println("the first node with value above " + k);
        System.out.println(EdgeFindOne.largerThan(root, k));
        
        int[] values7 = {-1, -8, -4};
        System.out.println("Layer order");
        root = EdgeFindOne.buildTree(values7);
        BTreePrinter.printNode(root);
        k = 6;
        System.out.println("the first node with value above " + k);
        System.out.println(EdgeFindOne.largerThan(root, k));
        
        int[] values8 = {16, -85, 26, -9, 52, -33, 0, -21, 93};
        System.out.println("Layer order");
        root = EdgeFindOne.buildTree(values8);
        BTreePrinter.printNode(root);
        k = 6;
        System.out.println("the first node with value above " + k);
        System.out.println(EdgeFindOne.largerThan(root, k));
    }
}