Explore our Solution Library

: 1436 144 2 471 0 0

Help me with my Scala Programming Assignment

Question - [1] def merge_sort(list: List[Int], cmp:(Int,Int)=>Boolean): List[Int] = { if (l1 == Nil) l2 else if (l2 == Nil) l1 else if (cmp(l1.head, l2.head)) l1.head :: merge(l1.tail, l2) else l2.head :: merge(l1, l2.tail) } list } else { val lngth = list.length val mid = lngth / 2 val a = list.slice(0, mid) val b = list.slice(mid, lngth) val sorted1 = merge_sort(a, cmp) val sorted2 = merge_sort(b, cmp) merge(sorted1, sorted2) } } val lte:(Int,Int)=>Boolean = _

Solution Preview - ist (13, 21, 35, 45, 73) - File name - Sort.scala Boolean - Either true or false Anonymous cmp is coming from its parent function "merge_sort", function "merge" is local for "merge_sort" and cmp is also local for "merge_sort". Therefore merge has access to use the cmp. A test code has also been written to prove this. (File name - Test.scala) 2)

Original Question Documents


Need finance assignment help at an affordable price? Hire our best academic writers to get the best Management paper. AllAssignmentHelp.com have subject experts from all the fields that can provide you more than 100 subjects’ help including history homework help , strategic assignment help,statistics assignment help . You can easily avail all these services from us at affordable prices. We are here to provide you the best writing service in any subject at very affordable prices. We have a team of very professional writers and also our executives can help you 24/7. Also, we give unlimited revision to the students.

Found What You Need?

Scroll down to find more if you need to find our more features

Place Your Order