[SOLVED] CS 431 Programming Language Concepts Homework 9

30.00 $

Programming resource
Digital learning resource
Category:
✓ Practical programming resource
✓ Suitable for guided study and reference
✓ Tutor guidance available when needed

Description

Rate this product

Homework 9
1 Scala Functions
For this homework, you will use Scala to implement three sorting functions.
1. Write a function merge_sort(lst: List[Int]): List[Int] that takes
a list, and return a sorted list in increasing order.
2. Write a function selection_sort(lst: List[Int]): List[Int] that
takes a list and return a sorted list in increasing order.
3. Write a function insertion_sort(lst: List[Int]): List[Int] that
takes a list and return a sorted list in increasing order.
You should place your methods inside an object and test them as follows.
Object Main{
// your sorting methods are placed here
def main(args: Array[String]) {
val lst = List(5,4,11,2,3,1,0,9)
println(merge_sort(lst))
println(selection_sort(lst))
println(insertion_sort(lst))
}
}
2 Submission
Please write your solution in a text le by the name of hwk9.scala and submit
it to the dropbox.
1

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.