def test_week1_quiz_Q1b(): """Test 3.""" alg = QuickFindUF(10) run_unions(alg, "4-7 7-8 9-7 6-5 8-6 2-0", "\ntest_week1_quiz_Q1b") chk_arrays(alg.ID, [0, 1, 0, 3, 5, 5, 5, 5, 5, 5])
def test_1(): """Test 1.""" alg = QuickFindUF(10) run_unions(alg, "4-3 3-8 6-5 9-4 2-1 8-9 5-0 7-2 6-1", "\ntest_1") chk_arrays(alg.ID, [1, 1, 1, 8, 8, 1, 1, 1, 8, 8])
def test_week1_quiz_Q1(): """Test 2.""" alg = QuickFindUF(10) run_unions(alg, "6-3 6-5 9-5 7-0 3-1 9-4", "\ntest_week1_quiz_Q1") chk_arrays(alg.ID, [0, 4, 2, 4, 4, 4, 4, 0, 8, 4])
def test_week1_exercise_Q2(): """Test 2.""" alg = QuickUnionUF(10) run_unions(alg, "1-2 7-9 0-4 8-0 4-6 1-9 3-4 7-0 0-5", "\ntest_week1_exercise_Q2") chk_arrays(alg.ID, [4, 2, 9, 6, 6, 5, 5, 9, 4, 6])
def test_week1_lecture(): """From Quick Union (7:50) Lecture Example.""" alg = QuickUnionUF(10) run_unions(alg, "4-3 3-8 6-5 9-4 2-1 8-9 5-0 7-2 6-1 7-3", "\nwk1_lec quick-union", "QU_demo") chk_arrays(alg.ID, [1, 8, 1, 8, 3, 0, 5, 1, 8, 8])
def test_week1_lecture(): """From Quick-Union Improvements (13:02) Lecture Example.""" alg = WeightedQuickUnionUF(10) run_unions(alg, "4-3 3-8 6-5 9-4 2-1 8-9 5-0 7-2 6-1 7-3", "\nwk1_lec quick-union", "WQU_demo") chk_arrays(alg.ID, [6, 2, 6, 4, 6, 6, 6, 2, 4, 4])