solutions to algorithmic questions