Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • (20 pts) Write the same mergesort function as described in exercise 26.1.2, except decompose the problem "top-down" rather than "bottom-up". You will need to define a function split: (list-of number) -> 2-element-structure-of-lists-of-number) that partitions its input into two lists of approximately (+/- 1) the same length in O(n) time where n is the length of the input list. (split l) returns a 2-element structure containing two lists of numbers. See below for hints in defining a 2-element structure.  After splitting the list in half, mergesort recursively sorts each half and then merges them together.   Be careful about attempting to split a one-element list!

Hints for writing the "split" function: 

...