Common algorithms written in Objective-C