Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using F# language. Full and complete answers in order to get full credit please.Thank you. Here is an attempt to write mergesortin F#: let rec
Using F# language. Full and complete answers in order to get full credit please.Thank you.
Here is an attempt to write mergesortin F#:
let rec merge = function | ([], ys) -> ys | (xs, []) -> xs | (x::xs, y::ys) -> if x < y then x :: merge (xs, y::ys) else y :: merge (x::xs, ys) let rec split = function | [] -> ([], []) | [a] -> ([a], []) | a::b::cs -> let (M,N) = split cs (a::M, b::N) let rec mergesort = function | [] -> [] | L -> let (M, N) = split L merge (mergesort M, mergesort N)
Analyze mergesort with respect to the Checklist for Programming with Recursion, again addressing all three Steps. (Assume that merge and split both work correctly, as indeed they do.)
Enter this program into F# and see what type F# infers for mergesort. Why is this type a clue that something is wrong with mergesort?
Based on your analysis, correct the bug in mergesort.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started