Bläddra i källkod

Upload files to ''

andrea.nieves7 1 år sedan
förälder
incheckning
74bc344fae
2 ändrade filer med 169 tillägg och 0 borttagningar
  1. 65
    0
      sorting.py
  2. 104
    0
      styles.js

+ 65
- 0
sorting.py Visa fil

@@ -0,0 +1,65 @@
1
+"""
2
+Carlos J Corrada Bravo
3
+Este programa calcula el promedio de tiempo de ejecucion de cuatro algoritmos de ordenamiento
4
+La variable maxValor define el valor maximo de los elementos de la lista
5
+La variable largoLista define el largo de las listas a ordenar
6
+La variable veces define las veces que se va a hacer el ordenamiento 
7
+Al final se imprimen los promedios de cada algortimo
8
+"""
9
+from random import randint
10
+import time
11
+
12
+def mergeSort(lista):
13
+	#definan el algoritmo de ordenamiento mergesort
14
+	return lista
15
+
16
+def heapSort(lista):
17
+	#definan el algoritmo de ordenamiento heapsort
18
+	return lista
19
+
20
+def quickSort(lista):
21
+	#definan el algoritmo de ordenamiento quicksort
22
+	return lista
23
+
24
+def shellSort(lista):
25
+	#definan el algoritmo de ordenamiento shellsort
26
+	return lista
27
+
28
+maxValor=1000 	#define el valor maximo de los elementos de la lista
29
+largoLista=1000 #define el largo de las listas a ordenar
30
+veces=100 		#define las veces que se va a hacer el ordenamiento 
31
+
32
+acumulaMerge=0 	#variable para acumular el tiempo de ejecucion del mergesort
33
+acumulaHeap=0 	#variable para acumular el tiempo de ejecucion del heapsort
34
+acumulaQuick=0 	#variable para acumular el tiempo de ejecucion del quicksort
35
+acumulaShell=0 	#variable para acumular el tiempo de ejecucion del shellsort
36
+
37
+for i in range(veces):
38
+	mergelista = [randint(0,maxValor) for r in range(largoLista)] #creamos una lista con valores al azar
39
+	heaplista=list(mergelista)
40
+	quicklista=list(mergelista)
41
+	searchlista=list(mergelista)
42
+
43
+	t1 = time.clock() 				#seteamos el tiempo al empezar
44
+	mergeSort(mergelista) 				#ejecutamos el algoritmo mergeSort
45
+	acumulaMerge+=time.clock()-t1 	#acumulamos el tiempo de ejecucion
46
+	
47
+	t1 = time.clock()				#seteamos el tiempo al empezar
48
+	heapSort(heaplista)					#ejecutamos el algoritmo heapSort
49
+	acumulaHeap+=time.clock()-t1 	#acumulamos el tiempo de ejecucion
50
+	
51
+	t1 = time.clock()				#seteamos el tiempo al empezar
52
+	quickSort(quicklista)				#ejecutamos el algoritmo quickSort
53
+	acumulaQuick+=time.clock()-t1 	#acumulamos el tiempo de ejecucion
54
+	
55
+	t1 = time.clock()				#seteamos el tiempo al empezar
56
+	shellSort(searchlista)				#ejecutamos el algoritmo shellSort
57
+	acumulaShell+=time.clock()-t1 	#acumulamos el tiempo de ejecucion
58
+
59
+#imprimos los resultados
60
+print "Promedio de tiempo de ejecucion de "+ str(veces) +" listas de largo " + str(largoLista)
61
+print "MergeSort " + str(acumulaMerge/veces) + " segundos"
62
+print "HeapSort " + str(acumulaHeap/veces) + " segundos"
63
+print "QuickSort " + str(acumulaQuick/veces) + " segundos"
64
+print "ShellSort " + str(acumulaShell/veces) + " segundos"
65
+

+ 104
- 0
styles.js Visa fil

@@ -0,0 +1,104 @@
1
+import { StyleSheet} from 'react-native';
2
+const styles = StyleSheet.create({
3
+	
4
+  buttons: {
5
+	  flexDirection: 'row',
6
+	  justifyContent: 'center',
7
+	  marginTop: 40,
8
+	  marginBottom: 30,
9
+	  margin: 30,
10
+	  borderColor: "grey",
11
+	  borderRadius: 8,
12
+	  padding: (30, 16),
13
+	  backgroundColor: "black",
14
+	  marginTop: 0,
15
+  }, 
16
+  navContainer: {
17
+	flexDirection: 'row',
18
+	justifyContent: "space-evenly",
19
+	borderColor: "black",
20
+	borderWidth: 5,
21
+	borderRadius: 8,
22
+	paddingTop: 20,
23
+	backgroundColor: "gray",
24
+	marginTop: 5,
25
+}, 
26
+  buttonContainer: {
27
+    flexDirection: 'column',
28
+    backgroundColor: '#f0f8ff',
29
+    alignItems: 'center',
30
+    justifyContent: 'center',
31
+	paddingTop:100,
32
+	marginTop: 40,
33
+  },
34
+  container: {
35
+    flexDirection: 'column',
36
+	justifyContent: 'center',
37
+    backgroundColor: '#f0f8ff',
38
+    alignItems: 'center',
39
+    justifyContent: 'center',
40
+	paddingTop:20,
41
+	marginTop: 20,
42
+  },
43
+  containerbackground:{
44
+	
45
+    backgroundColor: '#f0f8ff'
46
+  },
47
+  intro: {
48
+	  fontWeight: "bold",
49
+      color:"#black",
50
+	  fontSize: 30,
51
+  },
52
+
53
+  sub: {
54
+	color:"#black",  
55
+	fontWeight: "bold",
56
+	fontSize: 15,
57
+	paddingBottom:10,
58
+},
59
+
60
+  Navsub: {
61
+      color:"#black",  
62
+	  fontWeight: "bold",
63
+	  fontSize: 30,
64
+	  paddingBottom:10,
65
+  },
66
+  scrollView:{
67
+	  marginHorizontal: 20
68
+  },
69
+  listItem:{
70
+	  fontSize: 30,
71
+	  color: "white",
72
+	  textDecorationLines: "underline"
73
+  },
74
+  listButtons:{
75
+	  fontSize: 15,
76
+	  color: "white",
77
+	  textDecorationLines: "underline"  
78
+  },
79
+  buttonsVer: {
80
+	  flexDirection: 'column',
81
+	  justifyContent: 'center',
82
+	  marginTop: 40,
83
+	  marginBottom: 30,
84
+	  margin: 30,
85
+	  borderColor: "grey",
86
+  },
87
+  bottom: {
88
+    flex: 0.3,
89
+    backgroundColor: "gray",
90
+    borderWidth: 5,
91
+	alignItems: 'center',
92
+    borderBottomLeftRadius: 20,
93
+    borderBottomRightRadius: 20,
94
+  
95
+},text: {
96
+    fontSize: 16,
97
+    lineHeight: 21,
98
+    fontWeight: 'bold',
99
+    letterSpacing: 0.25,
100
+    color: 'white',
101
+  },
102
+});
103
+
104
+export {styles};