Question
Mergesort combining phase: 24 S = [] 25 while L != [] and R != []: 26 if head(L)
Mergesort combining phase:
24 S = [] 25 while L != [] and R != []: 26 if head(L) <= head(R): 27 S = S + [head(L)] 28 L = tail(L) 29 else: 30 S = S + [head(R)] 31 R = tail(R) 32 S = S + L + R 33 return S
Find the run time of mergesorts combining phase (lines 2433). Do not find the run time for the rest of mergesort. Do not use O, , or . Your answer must define T(n), where n is the number of elements to be sorted. Assume that head, tail, list concatenation +, and list creation [x], work in constant time. (This is probably not true in Python, but assume it anyway!) Like the example in Cormens text, also assume that the run times of lines 24, 25 ..., 33 are constants c, c ..., c. All these constants are greater than or equal to 0.
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