linear and binary search variations in java