sample code for various algorithms for my own understanding