|
@@ -30,52 +30,52 @@
|
30
|
30
|
"kind": 2,
|
31
|
31
|
"importPath": "heap",
|
32
|
32
|
"description": "heap",
|
33
|
|
- "peekOfCode": "def heapify(lista, n, i):\n\t\t# largest is root for now\n\t\tlargest = i\n\t\t# left child of root\n\t\tleft = 2 * i + 1\n\t\t# right child of root\n\t\tright = 2 * i + 2\n\t\t# Checks if root has a left child and is greater\n\t\t# than root\n\t\tif l < n and lista[i] < lista[l] :",
|
|
33
|
+ "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] :",
|
34
|
34
|
"detail": "heap",
|
35
|
35
|
"documentation": {}
|
36
|
36
|
},
|
37
|
37
|
{
|
38
|
|
- "label": "\t\tlargest",
|
|
38
|
+ "label": "\tlargest",
|
39
|
39
|
"kind": 5,
|
40
|
40
|
"importPath": "heap",
|
41
|
41
|
"description": "heap",
|
42
|
|
- "peekOfCode": "\t\tlargest = i\n\t\t# left child of root\n\t\tleft = 2 * i + 1\n\t\t# right child of root\n\t\tright = 2 * i + 2\n\t\t# Checks if root has a left child and is greater\n\t\t# than root\n\t\tif l < n and lista[i] < lista[l] :\n\t\t\tlargest = l\n\t\t# Checks if root has a right child and is greater",
|
|
42
|
+ "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",
|
43
|
43
|
"detail": "heap",
|
44
|
44
|
"documentation": {}
|
45
|
45
|
},
|
46
|
46
|
{
|
47
|
|
- "label": "\t\tleft",
|
|
47
|
+ "label": "\tl",
|
48
|
48
|
"kind": 5,
|
49
|
49
|
"importPath": "heap",
|
50
|
50
|
"description": "heap",
|
51
|
|
- "peekOfCode": "\t\tleft = 2 * i + 1\n\t\t# right child of root\n\t\tright = 2 * i + 2\n\t\t# Checks if root has a left child and is greater\n\t\t# than root\n\t\tif l < n and lista[i] < lista[l] :\n\t\t\tlargest = l\n\t\t# Checks if root has a right child and is greater\n\t\t# than root\n\t\tif r < n and lista[largest] < lista[r]:",
|
|
51
|
+ "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]:",
|
52
|
52
|
"detail": "heap",
|
53
|
53
|
"documentation": {}
|
54
|
54
|
},
|
55
|
55
|
{
|
56
|
|
- "label": "\t\tright",
|
|
56
|
+ "label": "\tr",
|
57
|
57
|
"kind": 5,
|
58
|
58
|
"importPath": "heap",
|
59
|
59
|
"description": "heap",
|
60
|
|
- "peekOfCode": "\t\tright = 2 * i + 2\n\t\t# Checks if root has a left child and is greater\n\t\t# than root\n\t\tif l < n and lista[i] < lista[l] :\n\t\t\tlargest = l\n\t\t# Checks if root has a right child and is greater\n\t\t# than root\n\t\tif r < n and lista[largest] < lista[r]:\n\t\t\tlargest = r\n\t\t# If necessary, this changes root by swapping va-",
|
|
60
|
+ "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-",
|
61
|
61
|
"detail": "heap",
|
62
|
62
|
"documentation": {}
|
63
|
63
|
},
|
64
|
64
|
{
|
65
|
|
- "label": "\t\t\tlargest",
|
|
65
|
+ "label": "\t\tlargest",
|
66
|
66
|
"kind": 5,
|
67
|
67
|
"importPath": "heap",
|
68
|
68
|
"description": "heap",
|
69
|
|
- "peekOfCode": "\t\t\tlargest = l\n\t\t# Checks if root has a right child and is greater\n\t\t# than root\n\t\tif r < n and lista[largest] < lista[r]:\n\t\t\tlargest = r\n\t\t# If necessary, this changes root by swapping va-\n\t\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)",
|
|
69
|
+ "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)",
|
70
|
70
|
"detail": "heap",
|
71
|
71
|
"documentation": {}
|
72
|
72
|
},
|
73
|
73
|
{
|
74
|
|
- "label": "\t\t\tlargest",
|
|
74
|
+ "label": "\t\tlargest",
|
75
|
75
|
"kind": 5,
|
76
|
76
|
"importPath": "heap",
|
77
|
77
|
"description": "heap",
|
78
|
|
- "peekOfCode": "\t\t\tlargest = r\n\t\t# If necessary, this changes root by swapping va-\n\t\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)",
|
|
78
|
+ "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)",
|
79
|
79
|
"detail": "heap",
|
80
|
80
|
"documentation": {}
|
81
|
81
|
},
|
|
@@ -84,7 +84,7 @@
|
84
|
84
|
"kind": 2,
|
85
|
85
|
"importPath": "sorting",
|
86
|
86
|
"description": "sorting",
|
87
|
|
- "peekOfCode": "def mergeSort(lista):\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\tfor i in range(h1, -1, -1):\n\t\tlista[i], lista[0] = lista[0], lista[i]",
|
|
87
|
+ "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):",
|
88
|
88
|
"detail": "sorting",
|
89
|
89
|
"documentation": {}
|
90
|
90
|
},
|
|
@@ -93,7 +93,7 @@
|
93
|
93
|
"kind": 2,
|
94
|
94
|
"importPath": "sorting",
|
95
|
95
|
"description": "sorting",
|
96
|
|
- "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\tfor i in range(h1, -1, -1):\n\t\tlista[i], lista[0] = lista[0], lista[i]\n\t\theap.heapify(lista, i, 0)\n\treturn lista\ndef quickSort(lista):",
|
|
96
|
+ "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",
|
97
|
97
|
"detail": "sorting",
|
98
|
98
|
"documentation": {}
|
99
|
99
|
},
|
|
@@ -120,7 +120,7 @@
|
120
|
120
|
"kind": 5,
|
121
|
121
|
"importPath": "sorting",
|
122
|
122
|
"description": "sorting",
|
123
|
|
- "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\tfor i in range(h1, -1, -1):\n\t\tlista[i], lista[0] = lista[0], lista[i]\n\t\theap.heapify(lista, i, 0)\n\treturn lista\ndef quickSort(lista):\n\t#definan el algoritmo de ordenamiento quicksort",
|
|
123
|
+ "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):",
|
124
|
124
|
"detail": "sorting",
|
125
|
125
|
"documentation": {}
|
126
|
126
|
},
|
|
@@ -129,7 +129,16 @@
|
129
|
129
|
"kind": 5,
|
130
|
130
|
"importPath": "sorting",
|
131
|
131
|
"description": "sorting",
|
132
|
|
- "peekOfCode": "\th1 = (n // 2) - 1\n\tfor i in range(h1, -1, -1):\n\t\theap.heapify(lista, n, i)\n\tfor i in range(h1, -1, -1):\n\t\tlista[i], lista[0] = lista[0], lista[i]\n\t\theap.heapify(lista, i, 0)\n\treturn lista\ndef quickSort(lista):\n\t#definan el algoritmo de ordenamiento quicksort\n\treturn lista",
|
|
132
|
+ "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",
|
|
133
|
+ "detail": "sorting",
|
|
134
|
+ "documentation": {}
|
|
135
|
+ },
|
|
136
|
+ {
|
|
137
|
+ "label": "\th2",
|
|
138
|
+ "kind": 5,
|
|
139
|
+ "importPath": "sorting",
|
|
140
|
+ "description": "sorting",
|
|
141
|
+ "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",
|
133
|
142
|
"detail": "sorting",
|
134
|
143
|
"documentation": {}
|
135
|
144
|
},
|