Exemplo n.º 1
0
    print(my_list[:10])
    sot = time.perf_counter()
    my_list = bubble_sort(my_list)
    eot = time.perf_counter()
    print("Total run time for bubble sort",eot-sot)
    print(my_list[:10])
#   shell sort
    my_list = [randint(0, 1000) for i in range(ARRAY_LENGTH)]
    print(my_list[:10])
    sot = time.perf_counter()
    my_list = shell_sort(my_list)
    eot = time.perf_counter()
    print("Total run time for shell sort",eot-sot)
    print(my_list[:10])
#   radix sort
    my_list = [randint(0, 1000) for i in range(ARRAY_LENGTH)]
    print(my_list[:10])
    sot = time.perf_counter()
    my_list = radix_sort(my_list)
    eot = time.perf_counter()
    print("Total run time for radix sort",eot-sot)
    print(my_list[:10])
#   heap sort
    my_list = [randint(0, 1000) for i in range(ARRAY_LENGTH)]
    print(my_list[:10])
    sot = time.perf_counter()
    my_list = heap_sort.max_heap_sort(my_list)
    eot = time.perf_counter()
    print("Total run time for heap sort",eot-sot)
    print(my_list[:10])
Exemplo n.º 2
0
 def test_radix_sort(self):
     self.assertEqual([1, 5, 23, 57, 65, 1232],
                      radix_sort([1, 5, 65, 23, 57, 1232]))
Exemplo n.º 3
0
 def test_radix_sort_simple(self):
     arr = [3, 2, 1]
     self.assertEqual(radix_sort(arr), sorted(arr))
Exemplo n.º 4
0
 def test_radix_sort(self):
     self.assertTrue(is_sorted(radix_sort([1, 3, 2, 5, 65, 23, 57, 1232])))
Exemplo n.º 5
0
 def test_radix_sort_similar_digits(self):
     arr = [10000, 1000, 100, 10, 0]
     self.assertEqual(radix_sort(arr), sorted(arr))
Exemplo n.º 6
0
 def test_radix_sort_complex_random(self):
     arr = random.sample(range(1000), 100)
     self.assertEqual(radix_sort(arr), sorted(arr))
Exemplo n.º 7
0
 def test_radix_sort_complex(self):
     arr = [170, 45, 75, 90, 2, 802, 2, 66]
     self.assertEqual(radix_sort(arr), sorted(arr))
Exemplo n.º 8
0
 def test_radix_sort(self):
     self.assertEqual([1, 5, 23, 57, 65, 1232],
                     radix_sort([1, 5, 65, 23, 57, 1232]))
Exemplo n.º 9
0
from algorithms.sort import radix_sort
import random

alist=[random.randint(1,100) for i in range(10)]
print(alist)
sorted_list=radix_sort(alist,simulation=True)
print(sorted_list)