3 Commits

Author SHA1 Message Date
  camila.vazquez1 56ceebacaa Commite merge nuevo 3 years ago
  camila.vazquez1 34d9cecf56 Merge con correccion Camila 3 years ago
  camila.vazquez1 63cb0b434b correccion de indentacion 3 years ago
1 changed files with 14 additions and 15 deletions
  1. 14
    15
      sorting.py

+ 14
- 15
sorting.py View File

@@ -25,27 +25,26 @@ def mergeSort(lista):
25 25
                 j = 0
26 26
                 k = 0
27 27
 
28
-        while i < len(L) and j < len(R):
29
-                if L[i] <= R[j]:
28
+                while i < len(L) and j < len(R):
29
+                        if L[i] <= R[j]:
30
+                                lista[k] = L[i]
31
+                                i += 1
32
+                        else:
33
+                                lista[k] = R[j]
34
+                                j += 1
35
+                        k += 1
36
+
37
+                while i < len(L):
30 38
                         lista[k] = L[i]
31 39
                         i += 1
32
-                else:
40
+                        k += 1
41
+
42
+                while j < len(R):
33 43
                         lista[k] = R[j]
34 44
                         j += 1
35
-                k += 1
36
-
37
-        while i < len(L):
38
-                lista[k] = L[i]
39
-                i += 1
40
-                k += 1
41
-
42
-        while j < len(R):
43
-                lista[k] = R[j]
44
-                j += 1
45
-                k += 1
45
+                        k += 1
46 46
 
47 47
         return lista
48
-
49 48
 def heapSort(lista):
50 49
 	#definan el algoritmo de ordenamiento heapsort
51 50
 	"""