def quicksort(arreglo,izq,der):
i=izq
j=der
piv=arreglo[(izq + der)/2]
while( i <= j ):
while arreglo[i]<piv and j<=der:
i=i+1
while piv<arreglo[j] and j>izq:
j=j-1
if i<=j:
aux = arreglo[i];
arreglo[i] = arreglo[j];
arreglo[j] = aux;
i=i+1;
j=j-1;
if izq < j:
quicksort( arreglo, izq, j );
if i < der:
quicksort( arreglo, i, der );
def imprimeLista(arreglo,tam):
for i in range(0,tam): print arreglo[i],
def leeLista():
arreglo=[]
a=int(raw_input("Ingresa el tamano del arreglo: "))
#for i in range(0,a):
# arreglo.append(int(raw_input("Ingresa los valores %d : " % i)))
arch = open('or.txt', 'r')
for linea in arch:
arreglo.append(linea.strip())
arch.close()
pos=int(raw_input("Selecciona el pivote: "))
return arreglo
A=leeLista()
tiempo_inicial = time()
quicksort(A,0,len(A)-1)
tiempo_final = time()
tiempo_ejecucion = tiempo_final - tiempo_inicial
print'El tiempo de ejecucion fue ::', tiempo_ejecucion
imprimeLista(A,len(A))
This is my code but it does not do the ordering just print the arrangement as it is
Result:
El tiempo de ejecucion fue :: 2.69412994385e-05
2,24,3,26,21,1, 4, 5, 29,6, 7, 8, 9, 10, 12, 13, 14, 15, 30,16, 17, 18, 19, 20, 22, 23, 25, 27, 28,11