Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 image text in transcribed
image text in transcribed
(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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Prepare and properly label figures and tables for written reports.

Answered: 1 week ago