add space and time complexity for chapter 18