Beispiel #1
0
 def test_counting_sort(self):
     self.assertEqual([1, 5, 23, 57, 65, 1232],
                      counting_sort([1, 5, 65, 23, 57, 1232]))
     self.assertEqual([-1232, -65, -57, -23, -5, -1],
                      counting_sort([-1, -5, -65, -23, -57, -1232]))
Beispiel #2
0
 def test_counting_sort(self):
     self.assertTrue(
         is_sorted(counting_sort([1, 3, 2, 5, 65, 23, 57, 1232])))
from algorithms.sort import counting_sort
import random

alist = [random.randint(1, 10) for i in range(100)]
print(alist)
sorted_list = counting_sort(alist)
print(sorted_list)
Beispiel #4
0
 def test_counting_sort(self):
     self.assertEqual([1, 5, 23, 57, 65, 1232],
                      counting_sort([1, 5, 65, 23, 57, 1232]))
     self.assertEqual([-1232, -65, -57, -23, -5, -1],
                      counting_sort([-1, -5, -65, -23, -57, -1232]))