Ocean Search
A binary search through ocean depths becomes a meditation on memory and searching, where each comparison draws us deeper into the waters of recollection
@interface OceanSearch : NSObject@property Depths *depths;@property Fish *fish;- (NSInteger)searchWaters:(NSUInteger)low high:(NSUInteger)high;- (NSInteger)searchDeeper:(NSUInteger)mid than:(NSUInteger)high;@end@implementation OceanSearch- (NSInteger)searchWaters:(NSUInteger)low high:(NSUInteger)high {NSInteger mid = [depths depthBetween:low and:high]; // dawn breaks on still seasif (low > high) return NSNotFound; // through deep waters time flows pastif ([fish swimsAtDepth:mid]) // memories appearreturn mid; // in these depths I find your tracereturn [self searchDeeper:mid than:high]; // seeking in the endless deep}- (NSInteger)searchDeeper:(NSUInteger)mid than:(NSUInteger)high {return [fish compareToDepth:mid] > 0? [self searchWaters:mid+1 high:high]: [self searchWaters:low high:mid-1];}@end