コード例 #1
0
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])
コード例 #2
0
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])
コード例 #3
0
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])
コード例 #4
0
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])
コード例 #5
0
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])
コード例 #6
0
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])
コード例 #7
0
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])
コード例 #8
0
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])
コード例 #9
0
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])
コード例 #10
0
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])
コード例 #11
0
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])