Browse Source

Arreglos en funcion heapSort. Prueba de heapSort anadida en test_sortAlgo.py

root 1 year ago
parent
commit
c21a14ed38
4 changed files with 19 additions and 1 deletions
  1. BIN
      __pycache__/sorting.cpython-38.pyc
  2. 1
    1
      sorting.py
  3. 18
    0
      test_sortAlgo.py
  4. BIN
      utils/__pycache__/qsortUtils.cpython-38.pyc

BIN
__pycache__/sorting.cpython-38.pyc View File


+ 1
- 1
sorting.py View File

@@ -77,7 +77,7 @@ def MAX_HEAPIFY(lista, index):
77 77
 	# Si el hijo izq es mayor que el padre
78 78
 	if lefti <= largo and lista[lefti] > lista[index]:
79 79
 		largest = lefti
80
-		else:
80
+	else:
81 81
 		largest = index
82 82
 
83 83
 	 # Si el hijo derecho es mayor que el padre

+ 18
- 0
test_sortAlgo.py View File

@@ -20,6 +20,23 @@ def test_mergeSort(pruebas):
20 20
         for nombre, lista in pruebas.items():
21 21
             print(f"{nombre}: Obtained -> {sorting.mergeSort(lista)} | Expected -> {sorted(lista)}")    
22 22
 
23
+def test_heapSort(pruebas):
24
+    FAIL = False
25
+
26
+    print("\nProbando HeapSort")
27
+
28
+    for nombre, lista in pruebas.items():
29
+        if sorting.heapSort(lista) == sorted(lista):
30
+            print(f"{nombre}: " + "Pass")
31
+        else:
32
+            print(f"{nombre}: " + "Fail")
33
+            FAIL = True
34
+
35
+    if FAIL == True and DEBUG_OUTPUT == True:
36
+        print("\n Test FAIL OUTPUT for HeapSort")
37
+        for nombre, lista in pruebas.items():
38
+            print(f"{nombre}: Obtained -> {sorting.heapSort(lista)} | Expected -> {sorted(lista)}")   
39
+
23 40
 def test_quickSort(pruebas):
24 41
     FAIL = False
25 42
 
@@ -62,6 +79,7 @@ def main():
62 79
                "Ordenada":[1,2,3,4,5,6,7]}
63 80
     
64 81
     test_mergeSort(PRUEBAS)
82
+    test_heapSort(PRUEBAS)
65 83
     test_quickSort(PRUEBAS)
66 84
     test_shellSort(PRUEBAS)
67 85
 

BIN
utils/__pycache__/qsortUtils.cpython-38.pyc View File