Implementations of several simple algorithms