Question: Scala programming (10 points) Write a function unionoftists that inputs two lists of integers (sorted in ascending order) and returns a list of integers. The

Scala programming  Scala programming (10 points) Write a function unionoftists that inputs two
lists of integers (sorted in ascending order) and returns a list of

(10 points) Write a function unionoftists that inputs two lists of integers (sorted in ascending order) and returns a list of integers. The function must compute the union of the two input lists to return a list that is also sorted in ascending order. Note that in performing the union, each number can appear at most once in the output list. Xxample 1: nput: List (1, 3, 4, 6) and List (2,3,4,5) Gutput: I.ist (1,2,3,4,5,6) xample 2: nput: Iist (1, 2, 3, 4) and List (1,2,3,5) Dutput: Iist (1, 2,3,4,5) Restrictions: Suppose the given lists are of the sizes n and m respectively, the algorithm you use should be of the time omplexity Q(n+m). Notice that you should never use any sorting program, since any comparison-based sorting algorithm has the time complexity O(klogk) where k is the size of the sorted sequence. lour program should pass the following tests: testwithMessagei testwithMessage l unionofists (List (1,2,3), List (1)), List (1,2,3), "unionofists (List (1,2,3), List (1))" ) Page 2 of 3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!