Esempio n. 1
0
 def test_same_element(self):
     arr = [1000000 for i in range(100000)]
     res = lab6.radix_sort(arr)
     subject = 0
     for x in range (100000):
         if res[x] >= subject:
             subject = res[x]
         else:
             subject = -1
             break
     self.assertTrue(subject != -1)
Esempio n. 2
0
 def test_not_trivial(self):
     arr = [randint(0, 100000) for i in range(100000)]
     res = lab6.radix_sort(arr)
     subject = 0
     for x in range (100000):
         if res[x] >= subject:
             subject = res[x]
         else:
             subject = -1
             break
     self.assertTrue(subject != -1)
Esempio n. 3
0
 def test_consecutive_integers(self):
     arr = [i for i in range(100000)]
     res = lab6.radix_sort(arr)
     subject = 0
     for x in range (100000):
         if res[x] >= subject:
             subject = res[x]
         else:
             subject = -1
             break
     self.assertTrue(subject != -1)
Esempio n. 4
0
import sys

__author__ = 'alexkane'
sys.path.insert(0, '/home/alexkane/PyRepository/lab4/Sadovnikov')
sys.path.insert(0, '/home/alexkane/PyRepository/lab5/Sadovnikov')
sys.path.insert(0, '/home/alexkane/PyRepository/lab6/Sadovnikov')
import matplotlib.pyplot as plt
import lab4
import lab5
import lab6

funcs = 4 * [None]
funcs[0] = lambda x: x.sort()
funcs[1] = lambda x: lab4.sort(x)
funcs[2] = lambda x: lab5.quick_sort(x, 0, len(x) - 1)
funcs[3] = lambda x: lab6.radix_sort(x)

array_of_names =  4 * [None]
array_of_names[0] = "Basic"
array_of_names[1] = "Merge/insert"
array_of_names[2] = "Quick"
array_of_names[3] = "Radix"


def universal_plot(fig, ax, term):
    xrng = xrange(100, 1000000, 100000)
    t = 0
    for func in funcs:
        array_of_medians = 10 * [None]
        m = 0
        for k in xrng:
Esempio n. 5
0
    def test_trivial(self):
        arr = [1, 333, 22]
        res = lab6.radix_sort(arr)
        expected = [1, 22, 333]

        self.assertEqual(expected, res)
Esempio n. 6
0
    def test_negative_element(self):
        arr = [-1, -333, -22]
        res = lab6.radix_sort(arr)
        expected = [-333, -22, -1]

        self.assertEqual(expected, res)
Esempio n. 7
0
 def test_empty(self):
     arr = []
     res = lab6.radix_sort(arr)
     expected = []
     self.assertEqual(expected, res)