Пример #1
0
def test_0(log):
    """Test using various random shuffles of a list of letters."""
    lst = ['K', 'B', 'C', 'I', 'E', 'G', 'F', 'H', 'J', 'D', 'A']
    L = len(lst)
    for i in range(10):
        shuffle(lst)
        bst = BST(sort_balbst(_get_kv(lst)))
        bst.wr_png("BST_a{I}.png".format(I=i))
        log.write("{LST}\n".format(LST=lst))
        assert bst.height() == int(np.floor(np.log2(L))), "HEIGHT VIOLATION"
Пример #2
0
def test_1(log):
    """Test using various random lists of integers."""
    for i in range(10):  # Run 10 tests
        L = random.randint(1, 100)
        lst = range(L)
        shuffle(lst)
        bst = BST(sort_balbst(_get_kv(lst)))
        bst.wr_png("BST_i{I}.png".format(I=i))
        log.write("{LST}\n".format(LST=lst))
        assert bst.height() == int(np.floor(np.log2(L))), "HEIGHT VIOLATION"
def test_1(log):
    """Test using various random lists of integers."""
    for i in range(10): # Run 10 tests
        L = random.randint(1, 100)
        lst = range(L)
        shuffle(lst)
        bst = BST(sort_balbst(get_kv(lst)))
        bst.wr_png("BST_i{I}.png".format(I=i))
        log.write("{LST}\n".format(LST=lst))
        assert bst.height() == int(np.floor(np.log2(L))), "HEIGHT VIOLATION"
def test_0(log):
    """Test using various random shuffles of a list of letters."""
    lst = ['K', 'B', 'C', 'I', 'E', 'G', 'F', 'H', 'J', 'D', 'A']
    L = len(lst)
    for i in range(10):
        shuffle(lst)
        bst = BST(sort_balbst(get_kv(lst)))
        bst.wr_png("BST_a{I}.png".format(I=i))
        log.write("{LST}\n".format(LST=lst))
        assert bst.height() == int(np.floor(np.log2(L))), "HEIGHT VIOLATION"
Пример #5
0
def main():
  """Test client."""
  #BST<String, Integer> st = new BST<String, Integer>()
  st = BST()
  st.put("A", 1)
  st.put("C", 2)
  st.put("E", 3)
  st.put("R", 4)
  st.put("H", 5)
  st.put("M", i)
  st.put("S", 6)
  st.put("X", 7)
Пример #6
0
def test_0(prt=sys.stdout):
    item_list = cli_get_array("tinyST.txt")
    print item_list
    st = BST()
    for i, key in enumerate(item_list):
        st.put(key, i)
        png = "BST_{I}_{K}.png".format(I=i, K=key)
        st.wr_png(png)

    prt.write("LEVEL ORDER:\n")
    for s in st.levelOrder():
        prt.write("{S} {ST}\n".format(S=s, ST=st.get(s)))

    prt.write("\n")

    prt.write("KEYS:\n")
    for s in st.keys():
        prt.write("{S} {ST}\n".format(S=s, ST=st.get(s)))

    st.wr_png("tinyST.png")
Пример #7
0
def test_0(prt=sys.stdout):
    item_list = cli_get_array("tinyST.txt")
    print item_list
    st = BST()
    for i, key in enumerate(item_list):
        st.put(key, i)
        png = "BST_{I}_{K}.png".format(I=i, K=key)
        st.wr_png(png)

    prt.write("LEVEL ORDER:\n")
    for s in st.levelOrder():
        prt.write("{S} {ST}\n".format(S=s, ST=st.get(s)))

    prt.write("\n")

    prt.write("KEYS:\n")
    for s in st.keys():
        prt.write("{S} {ST}\n".format(S=s, ST=st.get(s)))

    st.wr_png("tinyST.png")