Implement algorithms for chapter 5

Most of which are found at 5.8