Lecture 22: Merge sort
This assignment is due on Tuesday, November 1 at 11:59pm. Submit it using Handin as assignment lecture22.
5 6 2 1 8 2 3 7 |
Use this app to draw the decomposition. Make a rectangle for every problem.
Click the “Copy to clipboard” button in the lower-left corner of the app.
- Paste the code as a comment, like this:
; Merge sort: ; <bpmn:definitions ..... ..... ..... ; ..... ..... ..... ..... ..... ..... ; ..... ..... ..... ..... ..... ..... ; ..... ..... </bpmn:definitions>
; A MergeTree is one of: ; - (make-split MergeTree MergeTree) ; - (make-single Number) (define-struct split [former latter]) (define-struct single [element]) (define mt0 (make-single 8)) (define mt1 (make-split mt0 (make-single 2))) (define mt2 (make-split mt1 (make-split (make-single 3) (make-single 7))))
5 6 2 1 8 2 3 7 |
Exercise 3. Write the template for a function that processes a MergeTree. Make it look like a function called process-mergetree, and do not put it in a comment.
5 6 2 1 8 2 3 7 |
Use this app to draw the decomposition. Make a rectangle for every problem.
Click the “Copy to clipboard” button in the lower-left corner of the app.
- Paste the code as a comment, like this:
; Insert sort: ; <bpmn:definitions ..... ..... ..... ; ..... ..... ..... ..... ..... ..... ; ..... ..... ..... ..... ..... ..... ; ..... ..... </bpmn:definitions>
The code written in the videos above is available for your reference. To download it, don’t use “Save Page As” or “Save As”; use “Save Link As” or “Download Linked File” in your Web browser. If you can’t find the command, try right-clicking or two-finger-tapping or long-pressing.
Optional: Read Chapters 25–26 of the textbook.