Exercise 2.1 Write a function suffixes of type a list –> a list of list that takes a list xs and returns a list of all the suffixes of xs in decreasing order of length. For example,
suffixes [1,2,3,4] = [[1,2,3,4], [2,3,4], [3,4], [4], [ ] ]
Show that the resulting list of suffixes can be generated in O(n) time and represented in O(n) space.
1 2 3 4 5 6 7 8 9 |
|