futzing mostly

cat-town
Dan Buch 13 years ago
parent 59465b1152
commit 828a0287fd

@ -1,4 +1,7 @@
# vim:fileencoding=utf-8
def insertion_sort(a):
""" Θ(n^2) """
for j in range(1, len(a)):
key = a[j]
i = j - 1

@ -15,7 +15,7 @@ class Test(unittest.TestCase):
self.assertEqual(expected, a)
def test_big_example(self):
def test_100_example(self):
tmpl = list(range(0, 1000))
a = tmpl[:]
random.shuffle(a)
@ -25,8 +25,17 @@ class Test(unittest.TestCase):
self.assertEqual(expected, a)
def test_bigger_example(self):
tmpl = list(range(0, 10000))
def test_reversed_100_example(self):
tmpl = list(range(0, 1000))
a = list(reversed(tmpl[:]))
expected = tmpl[:]
insertion_sort01.insertion_sort(a)
self.assertEqual(expected, a)
def test_1000_example(self):
tmpl = list(range(0, 1000))
a = tmpl[:]
random.shuffle(a)
expected = tmpl[:]

Loading…
Cancel
Save