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

Throughout this assignment, adopt the following notation: a || B denotes the concatenation of lists a and B (in this order); & 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); 41=a+L(b-a)/3] and 12 = b-f(b-a)/31 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 1sis jsn such that A'[i] and A'[j] are both odd. 1. (1 point) Below is a self-reduction for that problem. State a recursive algorithm using pseudocode for solving the ODDSORT problem based on this self-reduction. OS(A[a...b]) = { if ab Ala) |OS(Ala+1...b]) if a
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
