Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Welcome, Kyle Blackbe X -spring 17/programming 2-374-spring-17.pdf 2. (30 points

ID: 3833606 • Letter: W

Question

Welcome, Kyle Blackbe X -spring 17/programming 2-374-spring-17.pdf 2. (30 points) Here is an SML mergesort program: fun merge (11, ys) ys I merge (xs, xs I merge (x xs, y: ys) if x y then x merge (xs, y: :ys) else y: merge (x :xs, ys) fun split (U, U) I split [a] (la I split (a :b: cs) let val (M, N split cs in (a: :M, b: N) end I) fun mergesort mergesort tal tal I merge sort la, bol if a b then lan, b1 else tb, al mergesort L let val (M,N) split L merge (mergesort M mergesort N end Note that mergesort includes three base cases (U, ta], ta,b1) and all are handled correctly. Suppose we delete the third line of mergesort, so that ta,b) is no longer handled as a base case. You can verify that this change makes no difference in the type of mergesort or in its behavior Now suppose we also delete the second line of me leaving

Explanation / Answer

This won't work properly as no base case is handled.

Example:

[1,2,3,4] is the array
it will be split into [1,2] and [3,4]
[1,2] further splits into [1] and [2]
Now, it will try to split [1] which is not possible and error is received

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote