Browse Source

fixed and ready to merge

final adjustments to shellsort algorithm
Orlando04 2 years ago
parent
commit
74e9149f67
1 changed files with 8 additions and 6 deletions
  1. 8
    6
      sorting.py

+ 8
- 6
sorting.py View File

21
 	#definan el algoritmo de ordenamiento quicksort
21
 	#definan el algoritmo de ordenamiento quicksort
22
 	return lista
22
 	return lista
23
 
23
 
24
+''' 
25
+	This algorithm was taken from: https://www.programiz.com/dsa/shell-sort 
26
+	and was adapted in order to work for this assigment.
27
+'''
28
+
24
 def shellSort(lista):
29
 def shellSort(lista):
25
 	#definan el algoritmo de ordenamiento shellsort
30
 	#definan el algoritmo de ordenamiento shellsort
26
-	# este algoritmo fue tomado de https://www.programiz.com/dsa/shell-sort 
27
-	# y adaptado para que funcione en este programa.
28
-	 
29
-	
30
-	# determinamos el tamaño de la lista para poder buscar el numero gap. 
31
+
32
+	# determening the size of the list and calculates the gap value. 
31
 	n = len(lista)
33
 	n = len(lista)
32
 	gap = n // 2
34
 	gap = n // 2
33
 
35
 
34
 	# this algorithm will run until gap reaches 1 
36
 	# this algorithm will run until gap reaches 1 
35
 	while gap > 0:
37
 	while gap > 0:
36
 		for i in range(gap, n):
38
 		for i in range(gap, n):
37
-			temp = lista[i] # storing all items from lista into temp 
39
+			temp = lista[i] # storing all items from the list into temp 
38
 			j = i 
40
 			j = i 
39
 
41
 
40
 			# compares the number in temp with the 0th possition (start of list)
42
 			# compares the number in temp with the 0th possition (start of list)