Answered step by step
Verified Expert Solution
Question
1 Approved Answer
25. ( points.) Lein and be no negative egers. What does MAKE-SETSh, Kloomipute! Tour answer rust be one short sentence, Slate G 3. (10 points.)
25. ( points.) Lein and be no negative egers. What does MAKE-SETSh, Kloomipute! Tour answer rust be one short sentence, Slate G 3. (10 points.) The following code fragment is the combining phase of the procedure MERGESORT, which was discussed in the lectures. It is written in Curren's pseudocode. 1 S=11 2 while Land R+! 3 if HEAD(L) HEATAR) 4 S = S + [HEAD(L)] 5 L=TAI (I.) else 7 S=S+ [HEAD(R) 1 8 RETAILER) 9 S=S+I.+R The variables L, R, and are lists of integers. The empty list is written us. Integers in L and X are sorted into dondecreasing order. The code fragment combines 1. and into a single lists, which is also sorted into nondecreasing order. The procedure TICAD returns the first element in a list. The procedure Tall retumis a list without its first element. The operator 'Tetams the concutention of two lists, and returns a list with one clements. Assume that HEAD, TAIL. und '+' execute in constant time for any lists. Assume that .x executes in constant time for any x. Suppose that L + R hus elements. What is the worst case runtime TYM) of this code frugment? You must write 7Yn) as an expression using and some constants, as Comen did when he competed the run time of his insertion sort algorithm. Here are some hints. You do not know what integers are in Land R. You know that either L. and are the sume length, or else L has one more integer than R, because of how the splitting phase works, You do not know how often HEAD(I.) S TAI (R) is true or false, because that depends on the integers in Lund . You may assume that the else in line 6 executes in constant time. my how in it your work 307
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started