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

2. (10 points) Write a function unionofists that inputs two lists of integers (sorted in ascending order) and returns 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. Example 1: Input: List (1,3,4,6) and List (2,3,4,5) Output: List (1,2,3,4,5,6) Example 2: Ipput: List (1,2,3,4) and List (1,2,3,5) Output: List (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 complexity O(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. Your program should pass the following tests: testwithonessagel yaionoftaists (List (1,3,5), List (2,3,4)), List (1,2,3,4,5), "unionoftists(List (1,3,5),List(2,3,4)) " 5estisthMessages yaigneftists(List (1) ) List (1)), List (1). "unionofists (List (1), List (1))" 5eschithuessagel ynionofidsts (Iist (1), List (1,2,3)), List (1,2,3), testwithMessage l unionofists (Iist () , List (0)), List (0), "unionofists(List (), List (0))" testwithMessagel unionofists (List (0), List ()), Iist (0), "unionoflists (List (0), List ()) " testwithMessage! unionoftists (List (2,4,6,8,10,12), List (1,3,5,7,9,11)), List (1,2,3,4,5,6,7,8,9,10,11,12), "unionoflists (List (2,4,6,8,10,12), List (1, 3, 5, 7, 9, 11))" score =(score115/7.0). round /1.0 passed (score)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
