Searching and Selection

Find a value in an array, or find the ith smallest element without sorting. Indices start at 1, as in CLRS.

Algorithm:
Speed:
Sample input:

Binary search needs a sorted array; unsorted input is sorted first.