123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- [
- {
- "label": "time",
- "kind": 6,
- "isExtraImport": true,
- "importPath": "time",
- "description": "time",
- "detail": "time",
- "documentation": {}
- },
- {
- "label": "randint",
- "importPath": "random",
- "description": "random",
- "isExtraImport": true,
- "detail": "random",
- "documentation": {}
- },
- {
- "label": "heap",
- "kind": 6,
- "isExtraImport": true,
- "importPath": "heap",
- "description": "heap",
- "detail": "heap",
- "documentation": {}
- },
- {
- "label": "heapify",
- "kind": 2,
- "importPath": "heap",
- "description": "heap",
- "peekOfCode": "def heapify(lista, n, i):\n\t# largest is root for now\n\tlargest = i\n\t# left child of root\n\tl = 2 * i + 1\n\t# right child of root\n\tr = 2 * i + 2\n\t# Checks if root has a left child and is greater\n\t# than root\n\tif l < n and lista[i] < lista[l] :",
- "detail": "heap",
- "documentation": {}
- },
- {
- "label": "\tlargest",
- "kind": 5,
- "importPath": "heap",
- "description": "heap",
- "peekOfCode": "\tlargest = i\n\t# left child of root\n\tl = 2 * i + 1\n\t# right child of root\n\tr = 2 * i + 2\n\t# Checks if root has a left child and is greater\n\t# than root\n\tif l < n and lista[i] < lista[l] :\n\t\tlargest = l\n\t# Checks if root has a right child and is greater",
- "detail": "heap",
- "documentation": {}
- },
- {
- "label": "\tl",
- "kind": 5,
- "importPath": "heap",
- "description": "heap",
- "peekOfCode": "\tl = 2 * i + 1\n\t# right child of root\n\tr = 2 * i + 2\n\t# Checks if root has a left child and is greater\n\t# than root\n\tif l < n and lista[i] < lista[l] :\n\t\tlargest = l\n\t# Checks if root has a right child and is greater\n\t# than root\n\tif r < n and lista[largest] < lista[r]:",
- "detail": "heap",
- "documentation": {}
- },
- {
- "label": "\tr",
- "kind": 5,
- "importPath": "heap",
- "description": "heap",
- "peekOfCode": "\tr = 2 * i + 2\n\t# Checks if root has a left child and is greater\n\t# than root\n\tif l < n and lista[i] < lista[l] :\n\t\tlargest = l\n\t# Checks if root has a right child and is greater\n\t# than root\n\tif r < n and lista[largest] < lista[r]:\n\t\tlargest = r\n\t# If necessary, this changes root by swapping va-",
- "detail": "heap",
- "documentation": {}
- },
- {
- "label": "\t\tlargest",
- "kind": 5,
- "importPath": "heap",
- "description": "heap",
- "peekOfCode": "\t\tlargest = l\n\t# Checks if root has a right child and is greater\n\t# than root\n\tif r < n and lista[largest] < lista[r]:\n\t\tlargest = r\n\t# If necessary, this changes root by swapping va-\n\t# lues\n\t\tlista[i], lista[largest] = lista[largest], lista[i]\n\t\t# This heapifies the root repeatedly\n\t\theapify(lista, n, largest)",
- "detail": "heap",
- "documentation": {}
- },
- {
- "label": "\t\tlargest",
- "kind": 5,
- "importPath": "heap",
- "description": "heap",
- "peekOfCode": "\t\tlargest = r\n\t# If necessary, this changes root by swapping va-\n\t# lues\n\t\tlista[i], lista[largest] = lista[largest], lista[i]\n\t\t# This heapifies the root repeatedly\n\t\theapify(lista, n, largest)",
- "detail": "heap",
- "documentation": {}
- },
- {
- "label": "mergeSort",
- "kind": 2,
- "importPath": "sorting",
- "description": "sorting",
- "peekOfCode": "def mergeSort(lista, l, r):\n\t# definan el algoritmo de ordenamiento mergesort\n\treturn lista\ndef heapSort(lista):\n\tn = len(lista)\n\th1 = (n // 2) - 1\n\tfor i in range(h1, -1, -1):\n\t\theap.heapify(lista, n, i)\n\th2 = n - 1\n\tfor i in range(h2, 0, -1):",
- "detail": "sorting",
- "documentation": {}
- },
- {
- "label": "heapSort",
- "kind": 2,
- "importPath": "sorting",
- "description": "sorting",
- "peekOfCode": "def heapSort(lista):\n\tn = len(lista)\n\th1 = (n // 2) - 1\n\tfor i in range(h1, -1, -1):\n\t\theap.heapify(lista, n, i)\n\th2 = n - 1\n\tfor i in range(h2, 0, -1):\n\t\tlista[i], lista[0] = lista[0], lista[i]\n\t\theap.heapify(lista, 0, i)\n\treturn lista",
- "detail": "sorting",
- "documentation": {}
- },
- {
- "label": "quickSort",
- "kind": 2,
- "importPath": "sorting",
- "description": "sorting",
- "peekOfCode": "def quickSort(lista):\n\t#definan el algoritmo de ordenamiento quicksort\n\treturn lista\ndef shellSort(lista):\n\t#definan el algoritmo de ordenamiento shellsort\n\treturn lista\nmaxValor=1000 \t#define el valor maximo de los elementos de la lista\nlargoLista=1000 \t#define el largo de las listas a ordenar\nveces=100 \t\t#define las veces que se va a hacer el ordenamiento\nacumulaMerge=0 \t#variable para acumular el tiempo de ejecucion del mergesort",
- "detail": "sorting",
- "documentation": {}
- },
- {
- "label": "shellSort",
- "kind": 2,
- "importPath": "sorting",
- "description": "sorting",
- "peekOfCode": "def shellSort(lista):\n\t#definan el algoritmo de ordenamiento shellsort\n\treturn lista\nmaxValor=1000 \t#define el valor maximo de los elementos de la lista\nlargoLista=1000 \t#define el largo de las listas a ordenar\nveces=100 \t\t#define las veces que se va a hacer el ordenamiento\nacumulaMerge=0 \t#variable para acumular el tiempo de ejecucion del mergesort\nacumulaHeap=0 \t#variable para acumular el tiempo de ejecucion del heapsort\nacumulaQuick=0 \t#variable para acumular el tiempo de ejecucion del quicksort\nacumulaShell=0 \t#variable para acumular el tiempo de ejecucion del shellsort",
- "detail": "sorting",
- "documentation": {}
- },
- {
- "label": "\tn",
- "kind": 5,
- "importPath": "sorting",
- "description": "sorting",
- "peekOfCode": "\tn = len(lista)\n\th1 = (n // 2) - 1\n\tfor i in range(h1, -1, -1):\n\t\theap.heapify(lista, n, i)\n\th2 = n - 1\n\tfor i in range(h2, 0, -1):\n\t\tlista[i], lista[0] = lista[0], lista[i]\n\t\theap.heapify(lista, 0, i)\n\treturn lista\ndef quickSort(lista):",
- "detail": "sorting",
- "documentation": {}
- },
- {
- "label": "\th1",
- "kind": 5,
- "importPath": "sorting",
- "description": "sorting",
- "peekOfCode": "\th1 = (n // 2) - 1\n\tfor i in range(h1, -1, -1):\n\t\theap.heapify(lista, n, i)\n\th2 = n - 1\n\tfor i in range(h2, 0, -1):\n\t\tlista[i], lista[0] = lista[0], lista[i]\n\t\theap.heapify(lista, 0, i)\n\treturn lista\ndef quickSort(lista):\n\t#definan el algoritmo de ordenamiento quicksort",
- "detail": "sorting",
- "documentation": {}
- },
- {
- "label": "\th2",
- "kind": 5,
- "importPath": "sorting",
- "description": "sorting",
- "peekOfCode": "\th2 = n - 1\n\tfor i in range(h2, 0, -1):\n\t\tlista[i], lista[0] = lista[0], lista[i]\n\t\theap.heapify(lista, 0, i)\n\treturn lista\ndef quickSort(lista):\n\t#definan el algoritmo de ordenamiento quicksort\n\treturn lista\ndef shellSort(lista):\n\t#definan el algoritmo de ordenamiento shellsort",
- "detail": "sorting",
- "documentation": {}
- },
- {
- "label": "\tmergelista",
- "kind": 5,
- "importPath": "sorting",
- "description": "sorting",
- "peekOfCode": "\tmergelista = [randint(0,maxValor) for r in range(largoLista)] #creamos una lista con valores al azar\n\theaplista=list(mergelista)\n\tquicklista=list(mergelista)\n\tsearchlista=list(mergelista)\n\tt1 = time.process_time()\t\t\t\t\t#tomamos el tiempo inicial\n\tmergeSort(mergelista,0,len(mergelista)-1) \t#ejecutamos el algoritmo mergeSort\n\tacumulaMerge+=time.process_time() - t1\t\t#acumulamos el tiempo de ejecucion\n\tprint(mergelista)\t\t\t\t\t\t\t#desplegamos la lista\n\tt1 = time.process_time()\t\t\t\t#tomamos el tiempo inicial\n\theapSort(heaplista)\t\t\t\t\t #ejecutamos el algoritmo heapSort",
- "detail": "sorting",
- "documentation": {}
- },
- {
- "label": "\tt1",
- "kind": 5,
- "importPath": "sorting",
- "description": "sorting",
- "peekOfCode": "\tt1 = time.process_time()\t\t\t\t\t#tomamos el tiempo inicial\n\tmergeSort(mergelista,0,len(mergelista)-1) \t#ejecutamos el algoritmo mergeSort\n\tacumulaMerge+=time.process_time() - t1\t\t#acumulamos el tiempo de ejecucion\n\tprint(mergelista)\t\t\t\t\t\t\t#desplegamos la lista\n\tt1 = time.process_time()\t\t\t\t#tomamos el tiempo inicial\n\theapSort(heaplista)\t\t\t\t\t #ejecutamos el algoritmo heapSort\n\tacumulaHeap+=time.process_time() - t1 \t#acumulamos el tiempo de ejecucion\n\tprint(heaplista)\t\t\t\t\t\t#desplegamos la lista\n\tt1 = time.process_time()\t\t\t\t#tomamos el tiempo inicial\n\tquickSort(quicklista)\t\t\t\t\t#ejecutamos el algoritmo quickSort",
- "detail": "sorting",
- "documentation": {}
- },
- {
- "label": "\tt1",
- "kind": 5,
- "importPath": "sorting",
- "description": "sorting",
- "peekOfCode": "\tt1 = time.process_time()\t\t\t\t#tomamos el tiempo inicial\n\theapSort(heaplista)\t\t\t\t\t #ejecutamos el algoritmo heapSort\n\tacumulaHeap+=time.process_time() - t1 \t#acumulamos el tiempo de ejecucion\n\tprint(heaplista)\t\t\t\t\t\t#desplegamos la lista\n\tt1 = time.process_time()\t\t\t\t#tomamos el tiempo inicial\n\tquickSort(quicklista)\t\t\t\t\t#ejecutamos el algoritmo quickSort\n\tacumulaQuick+=time.process_time() - t1\t#acumulamos el tiempo de ejecucion\n\tprint(quicklista)\t\t\t\t\t\t#desplegamos la lista\n\tt1 = time.process_time()\t\t\t\t#tomamos el tiempo inicial\n\tshellSort(searchlista)\t\t\t\t\t#ejecutamos el algoritmo shellSort",
- "detail": "sorting",
- "documentation": {}
- },
- {
- "label": "\tt1",
- "kind": 5,
- "importPath": "sorting",
- "description": "sorting",
- "peekOfCode": "\tt1 = time.process_time()\t\t\t\t#tomamos el tiempo inicial\n\tquickSort(quicklista)\t\t\t\t\t#ejecutamos el algoritmo quickSort\n\tacumulaQuick+=time.process_time() - t1\t#acumulamos el tiempo de ejecucion\n\tprint(quicklista)\t\t\t\t\t\t#desplegamos la lista\n\tt1 = time.process_time()\t\t\t\t#tomamos el tiempo inicial\n\tshellSort(searchlista)\t\t\t\t\t#ejecutamos el algoritmo shellSort\n\tacumulaShell+=time.process_time() - t1\t#acumulamos el tiempo de ejecucion\n\tprint(searchlista)\t\t\t\t\t\t#desplegamos la lista\n#imprimos los resultados\nprint (\"Promedio de tiempo de ejecucion de \"+ str(veces) +\" listas de largo \" + str(largoLista))",
- "detail": "sorting",
- "documentation": {}
- },
- {
- "label": "\tt1",
- "kind": 5,
- "importPath": "sorting",
- "description": "sorting",
- "peekOfCode": "\tt1 = time.process_time()\t\t\t\t#tomamos el tiempo inicial\n\tshellSort(searchlista)\t\t\t\t\t#ejecutamos el algoritmo shellSort\n\tacumulaShell+=time.process_time() - t1\t#acumulamos el tiempo de ejecucion\n\tprint(searchlista)\t\t\t\t\t\t#desplegamos la lista\n#imprimos los resultados\nprint (\"Promedio de tiempo de ejecucion de \"+ str(veces) +\" listas de largo \" + str(largoLista))\nprint (\"MergeSort \" + str(acumulaMerge/veces) + \" segundos\")\nprint (\"HeapSort \" + str(acumulaHeap/veces) + \" segundos\")\nprint (\"QuickSort \" + str(acumulaQuick/veces) + \" segundos\")\nprint (\"ShellSort \" + str(acumulaShell/veces) + \" segundos\")",
- "detail": "sorting",
- "documentation": {}
- }
- ]
|