Quick implementations of basic algorithms