Browse Source

Corrected indentations in sorting.py

luislopez66 2 years ago
parent
commit
b540f848cb
1 changed files with 17 additions and 17 deletions
  1. 17
    17
      sorting.py

+ 17
- 17
sorting.py View File

@@ -13,7 +13,7 @@ Al final se imprimen los promedios de cada algortimo
13 13
 from random import randint
14 14
 import time
15 15
 from merge import merge
16
-from heap import heap
16
+import heap
17 17
 
18 18
 # Python program for implementation of MergeSort
19 19
 
@@ -22,29 +22,29 @@ from heap import heap
22 22
 # Second subarray is arr[m+1..r]
23 23
 
24 24
 def mergeSort(lista, l, r):
25
-	if l < r:
25
+		if l < r:
26 26
 
27
-	# Same as (l+r)//2, but avoids overflow for
28
-	# large l and h
29
-	m = l+(r-l)//2
27
+		# Same as (l+r)//2, but avoids overflow for
28
+		# large l and h
29
+		m = l+(r-l)//2
30 30
 
31
-	# Sort first and second halves
32
-	mergeSort(lista, l, m)
33
-	mergeSort(lista, m+1, r)
34
-	merge(lista, l, m, r)
31
+		# Sort first and second halves
32
+		mergeSort(lista, l, m)
33
+		mergeSort(lista, m+1, r)
34
+		merge(lista, l, m, r)
35 35
 
36 36
 def heapSort(lista):
37 37
 
38
-	n = len(lista)
39
-	h1 = (n // 2) - 1
40
-	for i in range(h1, -1, -1):
41
-		heapify(lista, n, i)
38
+		n = len(lista)
39
+		h1 = (n // 2) - 1
40
+		for i in range(h1, -1, -1):
41
+			heapify(lista, n, i)
42 42
 
43
-	for i in range(h1, -1, -1):
44
-		lista[i], lista[0] = lista[0], lista[i]
45
-		heapify(lista, i, 0)
43
+		for i in range(h1, -1, -1):
44
+			lista[i], lista[0] = lista[0], lista[i]
45
+			heapify(lista, i, 0)
46 46
 
47
-	return lista
47
+		return lista
48 48
 
49 49
 def quickSort(lista):
50 50
 	#definan el algoritmo de ordenamiento quicksort