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
#include <stdbool.h> | |
void swap(void **vector,int a,int b){ | |
void *aux=vector[a]; | |
vector[a]=vector[b]; | |
vector[b]=aux; | |
} | |
int pivotear(void **vector,int cantidad, int (*comparador) (void*, void*)){ | |
int pos_pivote=cantidad-1; | |
int pos_pivote_final=0; |
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 merge(int *vector1, int cantidad1, int *vector2, int cantidad2, bool ascendente) | |
{ | |
int vector3[cantidad1 + cantidad2]; | |
int indice1 = 0, indice2 = 0, indice3 = 0; | |
if(ascendente){ | |
while(indice1 < cantidad1 && indice2 < cantidad2) | |
{ | |
if(vector1[indice1] < vector2[indice2]) | |
{ | |
vector3[indice3] = vector1[indice1]; |
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 swap(int*vector,int pos1,int pos2) | |
{ | |
int aux=vector[pos1]; | |
vector[pos1]=vector[pos2]; | |
vector[pos2]=aux; | |
} | |
void sift_down(struct heap*heap,int n) | |
{ | |
int hijo_izquierdo = 2*n+1; |
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
#include <stdbool.h> | |
void swap(int*vector,int a,int b){ | |
int aux=vector[a]; | |
vector[a]=vector[b]; | |
vector[b]=aux; | |
} | |
int pivotear(int*cosas,int cantidad, bool ascendente){ | |
int pos_pivote=cantidad-1; | |
int pos_pivote_final=0; |
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
|
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 procesar_linea_csv(linea): | |
nombre, apellido, edad = linea.rstrip('\n').split(',') | |
return nombre, apellido, edad |
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
archivo = open(RUTA) | |
linea = archivo.readline() | |
while(linea != “”): | |
print(linea, end = “”) | |
linea = archivo.readline() | |
archivo.close() |
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
try: | |
archivo = open(RUTA) | |
except FileNotFoundError: | |
archivo = open(RUTA, “w”) | |
archivo.close() | |
archivo = open(RUTA) |
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 busqueda_binaria(lista, item): | |
largo = len(lista) | |
min = 0 | |
max =largo | |
posicion = None | |
while (min <= max and posicion == None): | |
medio = (min+max)//2 | |
if lista[medio] == item: | |
posicion = medio |
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 busqueda_lineal(lista, item): | |
largo=len(lista) | |
encontrado = False | |
i = 0 | |
while i < largo and encontrado == False: | |
if lista[i]==item: | |
posicion =i | |
encontrado = True | |
i+=1 | |
return posicion |
NewerOlder