algorithms week 2, both questions answered