Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Throughout this assignment, adopt the following notation: a || B denotes the concatenation of lists a and B (in this order); e denotes the empty

image text in transcribed

Throughout this assignment, adopt the following notation: a || B denotes the concatenation of lists a and B (in this order); e denotes the empty string; len(s) 20 denotes the length (number of characters) on string s; minx(A[a...b]) denotes the index (in range [a...b]) of the minimum odd element from list A[a...b); h = a +[(b-a)/3] and 12 = b-[(b-a)/3] denote the indices at one third and two thirds the way from a lo b, respectively; pairsort(X,Y) denotes either Y | X (if X and Y are both odd and X > Y) or X | Y (other- wise). Consider the problem of sorting the odd elements in a list of integers while keeping the even ones unchanged in their original places. Sort the odd elements in a list (ODDSORT) Input: A[1...n] a list of integers. Output: List A'[l...n] such that A'[i] = A[i] if A'[i] is even, and A'[i] = A'[j] for all Isis jsn such that A'[i] and A' [j] are both odd. 2. (2+2 points) Using the same reduction as in the previous question, now state a re- currence T(n) that expresses the worst case running time of the recursive algorithm assuming that minx() runs in linear time. Solve that recurrence and state the tight (Big Theta) bound on T(n). Hint: look for a similar recurrence in the course notes. Throughout this assignment, adopt the following notation: a || B denotes the concatenation of lists a and B (in this order); e denotes the empty string; len(s) 20 denotes the length (number of characters) on string s; minx(A[a...b]) denotes the index (in range [a...b]) of the minimum odd element from list A[a...b); h = a +[(b-a)/3] and 12 = b-[(b-a)/3] denote the indices at one third and two thirds the way from a lo b, respectively; pairsort(X,Y) denotes either Y | X (if X and Y are both odd and X > Y) or X | Y (other- wise). Consider the problem of sorting the odd elements in a list of integers while keeping the even ones unchanged in their original places. Sort the odd elements in a list (ODDSORT) Input: A[1...n] a list of integers. Output: List A'[l...n] such that A'[i] = A[i] if A'[i] is even, and A'[i] = A'[j] for all Isis jsn such that A'[i] and A' [j] are both odd. 2. (2+2 points) Using the same reduction as in the previous question, now state a re- currence T(n) that expresses the worst case running time of the recursive algorithm assuming that minx() runs in linear time. Solve that recurrence and state the tight (Big Theta) bound on T(n). Hint: look for a similar recurrence in the course notes

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_2

Step: 3

blur-text-image_3

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

Database Development For Dummies

Authors: Allen G. Taylor

1st Edition

978-0764507526

More Books

Students also viewed these Databases questions

Question

Different formulas for mathematical core areas.

Answered: 1 week ago

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago