Esempio n. 1
0
 def test_find_max_crossing_subarray_allpositive(self):
     arr = [1, 1, 1, 1, 1]
     low = 0
     high = 4
     mid = (high + low) // 2
     expected_sum = high - low + 1
     expected = (low, high, expected_sum)
     actual = dac.find_max_crossing_subarray(arr, low, mid, high)
     self.assertEqual(expected, actual)
Esempio n. 2
0
 def test_find_max_crossing_subarray_withnegative(self):
     arr = [-7, 4, 1, -6, 2, -4, 10, -9]
     low = 1
     high = 6
     left_sum = -1
     right_sum = 8
     expected = (low, high, left_sum + right_sum)
     actual = dac.find_max_crossing_subarray(arr, 0, 3, 7)
     self.assertEqual(expected, actual)