Browse Source

Updated sorting.py with proper indentation?

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

+ 16
- 16
sorting.py View File

22
 # Second subarray is arr[m+1..r]
22
 # Second subarray is arr[m+1..r]
23
 
23
 
24
 def mergeSort(lista, l, r):
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
 def heapSort(lista):
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
 def quickSort(lista):
49
 def quickSort(lista):
50
 	#definan el algoritmo de ordenamiento quicksort
50
 	#definan el algoritmo de ordenamiento quicksort