def test_case_14(self): self.assertEqual( program.quickselect( [102, 41, 58, 81, 2, -5, 1000, 10021, 181, -14515, 25, 15], 5), 25) self.assertEqual( program.quickselect( [102, 41, 58, 81, 2, -5, 1000, 10021, 181, -14515, 25, 15], 5), 25)
def test_quickselect(): for i in range(100): N = np.random.randint(-100, 100, size=35) n = np.random.randint(35) kth = quickselect(N, n) assert kth == sorted(N)[n]
def test_case_2(self): self.assertEqual(program.quickselect([43, 24, 37], 1), 24)
def test_case_18(self): self.assertEqual( program.quickselect([ 1, 3, 71, 123, 124, 156, 814, 1294, 10024, 110000, 985181, 55516151125 ], 4), 123)
def test_case_1(self): self.assertEqual(program.quickselect([1], 1), 1)
def test_case_13(self): self.assertEqual(program.quickselect([8, 3, 2, 5, 1, 7, 4, 6], 8), 8)
def test_case_5(self): self.assertEqual(program.quickselect([8, 5, 2, 9, 7, 6, 3], 3), 5)
def test_case_4(self): self.assertEqual(program.quickselect([43, 24, 37], 3), 43)
def test_case_3(self): self.assertEqual(program.quickselect([43, 24, 37], 2), 37)