Searching
set low to 0 set high to size of array - 1 while high >= low calculate mid if searchfor < array[mid] high = mid -1 else if searchfor == array[mid] answer is mid else low = mid + 1Binary Search
int i, j; for (i=nElems-1; i > 0; i--) //all elems (exc 1st) for (j=0; j<; j++) // all unsorted elem pairs if (a[j] > a[j+1]) swap(j, j+1);
int i, j; for (i=nElems-1; i > 0; i--) //N-1 passes for (j=0; j<; j++) // N-1 + N-2 + ... + 2 + 1= N(N-1)/2 if (a[j] > a[j+1]) swap(j, j+1);
int i, j, minIndx; for (i=0; i < nElems-1; i++) { minIndx = i; for (j=i+1; j<nElems; j++) if (a[j] < a[minIndx]) minIndx = j; swap(i, minIndx); }