def test_bucket_sort(self): self.assertTrue(is_sorted(bucket_sort([1, 3, 2, 5, 65, 23, 57, 1232])))
def test_bucket_sort(self): self.assertEqual([1, 5, 23, 57, 65, 1232], bucket_sort([1, 5, 65, 23, 57, 1232]))
from algorithms.sort import (bucket_sort, next_sort, quick_sort) print(bucket_sort([1, 2, 3, 7, 8, 9, 4, 5, 6, 1, 1, 2])) print(quick_sort([1, 2, 3, 7, 8, 9, 4, 5, 6, 1, 1, 2]))
from algorithms.sort import bucket_sort import random alist = [random.randint(1, 10) for i in range(100)] print(alist) sorted_list = bucket_sort(alist) print(sorted_list)
def test_bucket_sort(self): self.assertEqual([1, 5, 23, 57, 65, 1232], bucket_sort([1, 5, 65, 23, 57, 1232]))
def test_bucket_sort_simple_even(self): arr = [4, 3, 2, 1] arr_copy = arr[::] arr_copy.sort() self.assertEqual(bucket_sort(arr), arr_copy)
def test_bucket_sort_large(self): arr = random.sample(range(500), 500) arr_copy = arr[::] arr_copy.sort() self.assertEqual(bucket_sort(arr), arr_copy)