Example #1
0
 def test_Insertion_3(self):
     insertion = Sort()
     listaDesordenada = [1, 2, 3, 4, 5]
     listaOrdenada = insertion.InsertionSort(listaDesordenada)
     self.assertEqual(listaOrdenada, [1, 2, 3, 4, 5])
Example #2
0
 def test_Merge_1(self):
     merge = Sort()
     listaDesordenada = [36, 71, 16, 21, 73, 9, 0, 40, 66, 5]
     listaOrdenada = merge.MergeSort(listaDesordenada)
     self.assertEqual(listaOrdenada, [0, 5, 9, 16, 21, 36, 40, 66, 71, 73])
Example #3
0
 def test_sorting_3(self):
     bubble = Sort()
     listaDes = [5, 0, 15, 25, 21, 35, 40, 25, 6, 9]
     listaOrd = bubble.BubbleSort(listaDes)
     self.assertEqual(listaOrd, [0, 5, 6, 9, 15, 21, 25, 25, 35, 40])
Example #4
0
 def test_Insertion_2(self):
     insertion = Sort()
     listaDesordenada = [1, -2, 3, -4, 5]
     listaOrdenada = insertion.InsertionSort(listaDesordenada)
     self.assertEqual(listaOrdenada, [-4, -2, 1, 3, 5])
Example #5
0
 def testArr3(self):
     arr3 = [5, 0, 15, 25, 21, 35, 40, 25, 6, 9]
     bubble3 = Sort().BubbleSort(arr3)
     self.assertEqual(bubble3, [0, 5, 6, 9, 15, 21, 25, 25, 35, 40])
Example #6
0
 def testList1(self):
     lista1 = [36, 71, 16, 21, 73, 9, 0, 40, 66, 7]
     bub1 = Sort().BubbleSort(lista1)
     self.assertEqual(InserLista(lista1), bub1)
Example #7
0
 def test_BubbleSort(self):
     arr = Sort().BubbleSort([36, 71, 16, 21, 73, 9, 0, 40, 66, 7])
     self.assertEqual(arr, [0, 7, 9, 16, 21, 36, 40, 66, 71, 73])
Example #8
0
 def test_Bubble_1(self):
     bubble = Sort()
     listaDesordenada = [36, 71, 16, 21, 73, 9, 0, 40, 66, 5]
     listaOrdenada = bubble.BubbleSort(listaDesordenada)
     self.assertEqual(listaOrdenada, [0, 5, 9, 16, 21, 36, 40, 66, 71, 73])
Example #9
0
 def test_sorting_2(self):
     lista = Sort().BubbleSort([0, 2, 23, 4, 2, 8, 1, 25, 6, 9])
     self.assertEqual(lista, [0, 1, 2, 2, 4, 6, 8, 9, 23, 25])
Example #10
0
 def test_2_BubbleSort(self):
     arr2 = Sort().BubbleSort([5, 0, 15, 25, 21, 35, 40, 25, 6, 9]) 
     self.assertEqual(arr2, [0, 5, 6, 9, 15, 21, 25, 25, 35, 40])
Example #11
0
 def test_sorting_1(self):
     lista = Sort().BubbleSort([36, 71, 16, 21, 73, 9, 0, 40, 66, 7])
     self.assertEqual(lista, [0, 7, 9, 16, 21, 36, 40, 66, 71, 73])
Example #12
0
 def test_sorting_3(self):
     lista = Sort().BubbleSort([5, 0, 15, 25, 21, 35, 40, 25, 6, 9])
     self.assertEqual(lista, [0, 5, 6, 9, 15, 21, 25, 25, 35, 40])
Example #13
0
 def test_sorting_1(self):
     bubble = Sort()
     listaDes = [36, 71, 16, 21, 73, 9, 0, 40, 66, 7]
     listaOrd = bubble.BubbleSort(listaDes)
     self.assertEqual(listaOrd, [0, 7, 9, 16, 21, 36, 40, 66, 71, 73])
Example #14
0
 def test_Merge_2(self):
     merge = Sort()
     listaDesordenada = [1, -2, 3, -4, 5]
     listaOrdenada = merge.MergeSort(listaDesordenada)
     self.assertEqual(listaOrdenada, [-4, -2, 1, 3, 5])
Example #15
0
 def test_1_BubbleSort(self):
     arr1 = Sort().BubbleSort([0, 2, 23, 4, 2, 8, 1, 25, 6, 9])
     self.assertEqual(arr1, [0, 1, 2, 2, 4, 6, 8, 9, 23, 25])
Example #16
0
 def test_Merge_3(self):
     merge = Sort()
     listaDesordenada = [1, 2, 3, 4, 5]
     listaOrdenada = merge.MergeSort(listaDesordenada)
     self.assertEqual(listaOrdenada, [1, 2, 3, 4, 5])
Example #17
0
 def test_Bubble_2(self):
     bubble = Sort()
     listaDesordenada = [1, -2, 3, -4, 5]
     listaOrdenada = bubble.BubbleSort(listaDesordenada)
     self.assertEqual(listaOrdenada, [-4, -2, 1, 3, 5])
Example #18
0
 def testArr2(self):
     arr2 = [0, 2, 23, 4, 2, 8, 1, 25, 6, 9]
     bubble2 = Sort().BubbleSort(arr2)
     self.assertEqual(bubble2, [0, 1, 2, 2, 4, 6, 8, 9, 23, 25])
Example #19
0
 def test_Bubble_3(self):
     bubble = Sort()
     listaDesordenada = [1, 2, 3, 4, 5]
     listaOrdenada = bubble.BubbleSort(listaDesordenada)
     self.assertEqual(listaOrdenada, [1, 2, 3, 4, 5])
Example #20
0
 def testArr1(self):
     arr1 = [36, 71, 16, 21, 73, 9, 0, 40, 66, 7]
     bubble1 = Sort().BubbleSort(arr1)
     self.assertEqual(bubble1, [0, 7, 9, 16, 21, 36, 40, 66, 71, 73])
Example #21
0
 def test_Insertion_1(self):
     insertion = Sort()
     listaDesordenada = [36, 71, 16, 21, 73, 9, 0, 40, 66, 5]
     listaOrdenada = insertion.InsertionSort(listaDesordenada)
     self.assertEqual(listaOrdenada, [0, 5, 9, 16, 21, 36, 40, 66, 71, 73])
Example #22
0
from timer import Timer
from sorting import Sort
import random

random_items = [random.randint(-50, 100) for c in range(5000)]
sort=Sort()

with Timer() as t:
    sort.bubble_sort(random_items)
print "=> elasped bubble_sort: %s s" % t.elapsed

with Timer() as t:
    sort.insertion_sort(random_items)
print "=> elasped insertion_sort: %s s" % t.elapsed
Example #23
0
 def test_sorting_2(self):
     bubble = Sort()
     listaDes = [0, 2, 23, 4, 2, 8, 1, 25, 6, 9]
     listaOrd = bubble.BubbleSort(listaDes)
     self.assertEqual(listaOrd, [0, 1, 2, 2, 4, 6, 8, 9, 23, 25])