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

Prolog. Anyone know this stuff? Thx so much. Write a predicate msort that sort a

ID: 3868763 • Letter: P

Question

Prolog. Anyone know this stuff? Thx so much.

Write a predicate msort that sort a list of integers using the merge sort method. Merge sort splits a list into two halves, recursively sorts each half and then merges them back together. You should expect to write a number of predicates for this question.?- msort ([4, 5, 3, 2, 2], M). M = [2, 2, 3, 4, 5].

Explanation / Answer

scala> List(1, 2) ::: List(3, 4, 5) res0: List[Int] = List(1, 2, 3, 4, 5) scala> List() ::: List(1, 2, 3) res1: List[Int] = List(1, 2, 3) scala> List(1, 2, 3) ::: List(4) res2: List[Int] = List(1, 2, 3, 4)