Implementations of some simple algorithms