Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Busqueda binaria version iterativa
#include <stdio.h> #define M 6 int busquedaBinariaIt(int *, int, int); int main(void) { int A[M] = {10, 20, 30, 40, 50, 60}; int clave = 50; int posicion = busquedaBinariaIt(A, M - 1, clave); if (posicion == -1) printf("%d NO ESTA EN VECTOR", clave); else printf("%d ESTA EN EL VECTOR EN POSICION %d", clave, posicion); return 0; } int busquedaBinariaIt(int * A, int N, int target) { int start; int end; int middle; start = 0; end = N; while ( start <= end) { middle = (start + end) / 2; if (A[middle] == target) return middle; else if (A[middle] > target) end = middle - 1; else start = middle + 1; } return -1; }
run
|
edit
|
history
|
help
0
18BCE2182 ASSESS_1 Q2-2
bitmask
variable number of arguments
C_141203_CadenasVarias
Lab6 v0.5 Sin,cos,tan,cot
Lab 7 blackjack v1.0
3850
Spring 2017 Project 2 v.04
Nice1
lab5