code for algorithms that I found useful