Created
June 6, 2018 08:44
-
-
Save Macorreag/cdc306fec5b323681ec09efc10ec08cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"collapsed": true | |
}, | |
"source": [ | |
"# QuickSort" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import random\n", | |
"import statistics\n", | |
"import math\n", | |
"\n", | |
"import matplotlib.pyplot as plt\n", | |
"%matplotlib inline" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 49, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"def randomquicksort(alist,times):\n", | |
" comp = [0]\n", | |
" randomquicksorthelper(alist,0,len(alist)-1,comp)\n", | |
" times.append(comp[0])" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"\n", | |
"def randomquicksorthelper(alist,first,last,comp):\n", | |
" if first<last:\n", | |
" r = randompartition(alist,first,last)\n", | |
" splitpoint = r[0]\n", | |
" tmp = comp.pop()\n", | |
" comp.append(tmp+r[1])\n", | |
" randomquicksorthelper(alist,first,splitpoint-1,comp)\n", | |
" randomquicksorthelper(alist,splitpoint+1,last,comp)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 50, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"def randompartition(alist,first,last):\n", | |
" indxpiv = random.randint(first,last)\n", | |
" temp = alist[indxpiv]\n", | |
" alist[indxpiv] = alist[first]\n", | |
" alist[first] = temp\n", | |
" \n", | |
" pivotvalue = alist[first]\n", | |
" compspart = 0\n", | |
"\n", | |
" leftmark = first+1\n", | |
" rightmark = last\n", | |
"\n", | |
" done = False\n", | |
" while not done:\n", | |
"\n", | |
" while leftmark <= rightmark and alist[leftmark] <= pivotvalue:\n", | |
" leftmark = leftmark + 1\n", | |
" compspart = compspart + 1\n", | |
" compspart = compspart + 1\n", | |
"\n", | |
" while alist[rightmark] >= pivotvalue and rightmark >= leftmark:\n", | |
" rightmark = rightmark -1\n", | |
" compspart = compspart + 1\n", | |
" compspart = compspart + 1\n", | |
"\n", | |
" if rightmark < leftmark:\n", | |
" done = True\n", | |
" else:\n", | |
" temp = alist[leftmark]\n", | |
" alist[leftmark] = alist[rightmark]\n", | |
" alist[rightmark] = temp\n", | |
" temp = alist[first]\n", | |
" alist[first] = alist[rightmark]\n", | |
" alist[rightmark] = temp\n", | |
" return rightmark,compspart\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 51, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"def RandomQuickSortTime(s, r):\n", | |
" # Create an array of 1 .. n\n", | |
" n = s\n", | |
" runs = r\n", | |
" x = []\n", | |
" for i in range(1, n + 1):\n", | |
" x.append(n + 1 - i)\n", | |
"\n", | |
" # Run quicksort for each permutation\n", | |
" tlist = []\n", | |
" for p in range(1, runs + 1):\n", | |
" y = list(x)\n", | |
" QuickSort(y, tlist)\n", | |
"\n", | |
" count = 0\n", | |
" for i in range(len(tlist)):\n", | |
" if (tlist[i] >= 96):\n", | |
" count += 1\n", | |
"\n", | |
" plt.hist(tlist, bins='auto', color='black')\n", | |
" plt.title(\"Number of comparison of Quicksort for all permutaions\")\n", | |
" plt.xlabel(\"Comparisons of elements\")\n", | |
" plt.ylabel(\"Frequency\")\n", | |
" plt.show()\n", | |
"\n", | |
" print (\"N:\", n)\n", | |
" print (\"Runs:\", runs)\n", | |
" print (\"Promedio teorico:\", 16 * math.log(16) / math.log(2))\n", | |
" print (\"Promedio experimental:\", statistics.mean(tlist))\n", | |
" print (\"Diferencia entre promedio teorico y experimental:\", statistics.mean(tlist) - 16 * math.log(16) / math.log(2))\n", | |
" print (\"Desviacion estandar:\", statistics.stdev(tlist))\n", | |
" print (\"Probabilidad que se demore 1.5 más que el promedio:\", float(count) / float(len(tlist)))\n", | |
" print (\"Min:\", min(tlist))\n", | |
" print (\"Max:\", max(tlist))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 52, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAaEAAAEWCAYAAADPZygPAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3XucHFWZ//HPl4T7LQQCYhIJQrwAqxECZL0iIARUgqusIEpEJOqCyq6uBPUnN13BGyyrorhkCSjEgApRwRC56iqXQQNJuGwGCBATIJAQAijX5/fHOS2VtrunZ0zPmTDf9+vVr6l+6lTVU9XV/XRVnalWRGBmZlbCOqUTMDOzwctFyMzMinERMjOzYlyEzMysGBchMzMrxkXIzMyKcREaoCSdJ+nLhZYtSf8jaYWkm0rk0AmSrpA0uXQeNZLeJGmhpCckHdyhZSyQtFcb7ULSjp3IoTckbSPpekmrJH2zH5a3SNK+efgkST/s9DIHAknfk/T/SucBLkJtyzvrQ5I2rsQ+Kunagml1ypuBdwCjImKP0smsKRFxQERML51HxSnAtyNik4i4tFEDSR+WNE/SU5IelPRdSZu3u4CI2Dkirl1TCf898rr8todmU4BHgM0i4jP9kNZLQrWYtiMiPh4Rp3Yyp3a5CPXOUODTpZPoLUlDejnJdsCiiHiyE/n0t3xkNxD39e2ABc1GSvoMcDrw78DmwARgDHClpHX7I8E1RdLQNptuB9weffgv+l4so6i1Jc9+ExF+tPEAFgFTgeXAsBz7KHBtHh4DBDC0Ms21wEfz8IeB/wXOAB4D7gHemOMPAA8DkyvTngd8D5gDrAKuA7arjH9NHrccuAv457ppzwYuB54E9m2wPi8HZuXpu4G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E+iGyS4FngNr1mFuAd+Th/wXOkzSTdEPZdtd5VovttB9wkKTP5ucbAK/oRZtrImIVsErSStLtaiBty9dJ2oR049uL09lTIBX/mkvzNr69dsTXwO+BL0gaBfw0Iha2WB9bi7gI2dpuAS/eTLVeo9vT11Svi7xQef4Cq78v6u9rFcC/ku6t9nrSN/i/VMY/2WhhEXG9pLcC7wQuyJ0DHm/UNns28td+UqEbmufzcUl75vnMlTQuIh6tTNdqnZsR8N6o+0G7uoLQrM2e9Lwt1yH9BtW4JsuvTt8w/4i4UNKNpPWeLemjEXF169WytYGvCdna7mpgfUlH1wKSdpf0NuB64P2ShkgaQTrK6O3dlQ+RtE6+TvRK0g0yNweW5m/vHyKd+mpJ0nbAwxHxA+Bc0s8u3wi8TdJWkoaQ7qh+XQ/z2SEiboyILwGPsPrt96Fv6zwb+KTyYYqkN/SxTUORfm30XkmH5Gkl6fU9TLaKdIqPPM0rgXsi4izSUd3r2l2+DWw+ErK1WkSEpPcAZ0qaSjoqWQQcR/pA/kfSHbYD+FxEPFi7KN6mu0iFYRvStY6/SPou8JP8oXoNTY5+6uwF/LukZ4EngCMiYqmkE/I8BFweET397MTX80V5ka6z1P9C5s9osM49zPNU4EzgtlxkFpF+s6e3bVo5HDhb0heBdYEZDXKvug14TtKtpOtGGwAfzNvvQeCUXizbBjDfRdusCUnnkS6OX1I6F7OXKp+OMzOzYnwkZGZmxfhIyMzMinERMjOzYlyEzMysGBchMzMrxkXIzMyK+f9B2UdsBl+eqQAAAABJRU5ErkJggg==\n", | |
"text/plain": [ | |
"<matplotlib.figure.Figure at 0x17e9ac10>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"N: 16\n", | |
"Runs: 10000000\n", | |
"Promedio teorico: 64.0\n", | |
"Promedio experimental: 83.6645058\n", | |
"Diferencia entre promedio teorico y experimental: 19.6645058\n", | |
"Desviacion estandar: 7.09159948607\n", | |
"Probabilidad que se demore 1.5 más que el promedio: 0.0658262\n", | |
"Min: 67\n", | |
"Max: 142\n" | |
] | |
} | |
], | |
"source": [ | |
"RandomQuickSortTime(16,10000000)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"Pruebas Tiempo \n", | |
"10000000 11.38 minutos\n", | |
"263620386,6432 5 horas\n" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.4" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment