Solve Exercise P14.6 in your textbook. Don't be one of those knuckleheads who asks on Piazza where that is. It's in your textbook.
Add a parameter debug
. If it is set to true
, print the ranges that you are merging, exactly in the following format:
Merging 0...1 and 2...3
In the draft, you may assume that the array length is a power of two, and you only print the messages. Don't actually do any merging. You can do this part without knowing what merge sort does.
For example, if the array has length 16, you print
Merging 0...0 and 1...1 Merging 2...2 and 3...3 Merging 4...4 and 5...5 Merging 6...6 and 7...7 Merging 8...8 and 9...9 Merging 10...10 and 11...11 Merging 12...12 and 13...13 Merging 14...14 and 15...15 Merging 0...1 and 2...3 Merging 4...5 and 6...7 Merging 8...9 and 10...11 Merging 12...13 and 14...15 Merging 0...3 and 4...7 Merging 8...11 and 12...15 Merging 0...7 and 8...15
In your solution, provide your pseudocode as comments.