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])
Example #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])
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_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])
Example #5
0
def test_week1_quiz_Q1_126228():
  """Test 126228."""
  alg = QuickFindUF(10)
  run_unions(alg, "8-9 4-0 8-5 2-6 1-7 0-3", "\nWeek 1 Exercise Question 1")
def test_week1_quiz_Q1_533243():
  """Test 6."""
  alg = QuickFindUF(10)
  run_unions(alg, "5-2 0-2 5-9 2-1 3-9 4-6", "\nWeek 1 Exercise Question 1")
def test_week1_quiz_Q1_126228():
  """Test 126228."""
  alg = QuickFindUF(10)
  run_unions(alg, "8-9 4-0 8-5 2-6 1-7 0-3", "\nWeek 1 Exercise Question 1")
Example #8
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])
Example #9
0
def test_week1_quiz_Q1_567561():
  """Test 4."""
  alg = QuickFindUF(10)
  run_unions(alg, "0-2 3-0 5-9 5-2 7-9 7-8", "\nWeek 1 Exercise Question 1")
Example #10
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])
Example #11
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])
Example #12
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])
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_quiz_Q1_567561():
  """Test 4."""
  alg = QuickFindUF(10)
  run_unions(alg, "0-2 3-0 5-9 5-2 7-9 7-8", "\nWeek 1 Exercise Question 1")
Example #16
0
def test_week1_quiz_Q1_838874():
  """Test 5."""
  alg = QuickFindUF(10)
  run_unions(alg, "9-1 8-0 6-1 4-0 6-0 1-7", "\nWeek 1 Exercise Question 1")
def test_week1_quiz_Q1_838874():
  """Test 5."""
  alg = QuickFindUF(10)
  run_unions(alg, "9-1 8-0 6-1 4-0 6-0 1-7", "\nWeek 1 Exercise Question 1")
Example #18
0
def test_week1_quiz_Q1_533243():
  """Test 6."""
  alg = QuickFindUF(10)
  run_unions(alg, "5-2 0-2 5-9 2-1 3-9 4-6", "\nWeek 1 Exercise Question 1")
def test_week1_quiz_Q1_489602():
  """Test 7."""
  alg = QuickFindUF(10)
  run_unions(alg, "2-7 9-6 8-1 5-9 0-8 9-1", "\nWeek 1 Exercise Question 1")
Example #20
0
def test_week1_quiz_Q1_489602():
  """Test 7."""
  alg = QuickFindUF(10)
  run_unions(alg, "2-7 9-6 8-1 5-9 0-8 9-1", "\nWeek 1 Exercise Question 1")
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_wk1_ex_455127():
  """Week 1 Exercise."""
  alg = WeightedQuickUnionUF(10)
  run_unions(alg, "8-7 7-0 9-6 5-4 4-6 8-3 1-0 7-6 7-2", "\nwk1 Ex", "work/Ex_wk1_455127")