This file contains hidden or 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
| void insertion_sort(char vector_desordenado[MAX_VECTOR], char vector_ordenado[MAX_VECTOR], int tope, bool ascendente){ | |
| int i, j; | |
| for(i = 0; i < tope; i++) | |
| vector_ordenado[i] = vector_desordenado[i]; | |
| for(i = 0; i < tope; i++){ | |
| int elemento_actual = vector_ordenado[i]; | |
| j = i-1; | |
| if(ascendente){ | |
| while (j >= 0 && elemento_actual < vector_ordenado[j]){ |
This file contains hidden or 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
| //A selection sort algorithm that sorts descendingly or ascendingly depending of the boolean parameter. | |
| void selection_sort(char vector_desordenado[MAX_VECTOR], char vector_ordenado[MAX_VECTOR], int tope, bool ascendente){ | |
| for(int i = 0, i < tope, i++) | |
| vector_ordenado[i] = vector_desordenado[i]; | |
| for (int i = 0; i < tope; i++){ | |
| int pos_min = i; | |
| for (int j = i + 1; j < tope; j++){ | |
| if (ascendente){ |
This file contains hidden or 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
| void bubble_sort(char vector_desordenado[MAX_VECTOR], char vector_ordenado[MAX_VECTOR], int tope, bool ascendente){ | |
| int j, i; | |
| for(i = 0; i < tope; i++){ | |
| for(j = 0; j < tope-1; j++){ | |
| if(ascendente){ | |
| if(vector_desordenado[j] > vector_desordenado[j+1]){ | |
| char aux = vector_desordenado[j]; | |
| vector_desordenado[j] = vector_desordenado[j+1]; | |
| vector_desordenado[j+1] = aux; | |
| } |
This file contains hidden or 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
| def cargar(diccionario, kkey, value): | |
| if key in diccionario.keys(): | |
| diccionario[kkey]+=value | |
| else: | |
| diccionario[kkey]=value |
NewerOlder