Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this item consider the problem of sorting the odd elements in a list of integers while Keeping the ones unchanged in their original places

image text in transcribed
image text in transcribed
For this item consider the problem of sorting the odd elements in a list of integers while Keeping the ones unchanged in their original places Sort the odd elements in a list ODDSORT Input: All... a list of integer Output List All...such that A'=A[ uch that and are both add is even, and for all Isis S Let OSIA a... represent the output of the ODDSORT problem on input Ala... Leta denote the concatenation of lists and B. and let it a...ll denote the index in range a.. of the minimum element from lista point I Below is a self-reduction for the ODOSORT problem. State arcursive algorithm using pseudocode for solving the DDESORT problem based on this self-reduction OSLA...) All OSLA +1...) AKOSA L...k-1 Ala Alk+1... faband All is even oras fac band Alalised and ack with Ala... (2.2 points 2. Using the same reduction as in ltem aboveno state a recurrence in that expresses the worst case running time of the cursive algorithm assuming that min runs in linear time. Solve that recurrence and state the tight By Thea bundan im Hint look for a similar recurrence in the course notes (point). Lethalibal/jandb -0)/31 denote the indices at one third and two thirds the way from a lob, respectively, Letra Y be a function that returns YX if X and Y are both odd and X Y, otherwise returns XY . Below is another self-reduction for the ODDSORT problem. State a recursive algorithm using pseudocode for solving the ODDSORT problem based on this self reduction ifa pairsorr Ala). ADD SOSIA ... T with ' A" A - SOSIAL... Alt+1... Nla... I SOSIA' 1...bl) S OSLAL... +1... 122 points) 4. Using the same reduction as in item 3 above, state a recurrence in that expresses the worst case running time of the recursive algorithm. From this recurrence, find a tight Big.Thetal expression for T .Hint: the Master Theorem may be the easiest solution Dobbordalandar 2 PROBLEMS 2.1 UNDERSTAND For this item 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: Al...n) a list of integers. Output: List All...n) such that A' [i] = A[i] if A'i is even, and A'lis Aljl for all lsis is n such that Ali and A'ljare both odd. Let OSCA[a...b]) represent the output of the ODDSORT problem on input Aa...b]. Let al denote the concatenation of lists a and B. and let minx(Ala...b]) denote the index (in range [a...bl) of the minimum odd element from list Ala...bj. (1 point) 1. Below is a self-reduction for the ODDSORT problem. State a recursive algorithm using pseudocode for solving the ODDSORT problem based on this self-reduction. OS(A[a... b]) = { A[a]IOS(Ala+1...b]) A[k]IOS(Ala+1...k-1] A[all Ak +1... b if a b if a Y, otherwise returns XIY. Below is another self-reduction for the ODDSORT problem. State a recursive algorithm using pseudocode for solving the ODDSORT problem based on this self-reduction pairsors(A[a], A[b]) if a b if b= a +1 if b> a+1 SOS(Ala...bl) = with A' A" A" - - - SOS(Ala... 12 A 12 +1...b] A'la...AI SOSIA'1+1...b]) SOSCA" la... 121 1A" [12 +1...b] (2+2 points) 4. Using the same reduction as in item 3 above, state a recurrence T') that expresses the worst case running time of the recursive algorithm. From this recurrence, find a tight For this item consider the problem of sorting the odd elements in a list of integers while Keeping the ones unchanged in their original places Sort the odd elements in a list ODDSORT Input: All... a list of integer Output List All...such that A'=A[ uch that and are both add is even, and for all Isis S Let OSIA a... represent the output of the ODDSORT problem on input Ala... Leta denote the concatenation of lists and B. and let it a...ll denote the index in range a.. of the minimum element from lista point I Below is a self-reduction for the ODOSORT problem. State arcursive algorithm using pseudocode for solving the DDESORT problem based on this self-reduction OSLA...) All OSLA +1...) AKOSA L...k-1 Ala Alk+1... faband All is even oras fac band Alalised and ack with Ala... (2.2 points 2. Using the same reduction as in ltem aboveno state a recurrence in that expresses the worst case running time of the cursive algorithm assuming that min runs in linear time. Solve that recurrence and state the tight By Thea bundan im Hint look for a similar recurrence in the course notes (point). Lethalibal/jandb -0)/31 denote the indices at one third and two thirds the way from a lob, respectively, Letra Y be a function that returns YX if X and Y are both odd and X Y, otherwise returns XY . Below is another self-reduction for the ODDSORT problem. State a recursive algorithm using pseudocode for solving the ODDSORT problem based on this self reduction ifa pairsorr Ala). ADD SOSIA ... T with ' A" A - SOSIAL... Alt+1... Nla... I SOSIA' 1...bl) S OSLAL... +1... 122 points) 4. Using the same reduction as in item 3 above, state a recurrence in that expresses the worst case running time of the recursive algorithm. From this recurrence, find a tight Big.Thetal expression for T .Hint: the Master Theorem may be the easiest solution Dobbordalandar 2 PROBLEMS 2.1 UNDERSTAND For this item 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: Al...n) a list of integers. Output: List All...n) such that A' [i] = A[i] if A'i is even, and A'lis Aljl for all lsis is n such that Ali and A'ljare both odd. Let OSCA[a...b]) represent the output of the ODDSORT problem on input Aa...b]. Let al denote the concatenation of lists a and B. and let minx(Ala...b]) denote the index (in range [a...bl) of the minimum odd element from list Ala...bj. (1 point) 1. Below is a self-reduction for the ODDSORT problem. State a recursive algorithm using pseudocode for solving the ODDSORT problem based on this self-reduction. OS(A[a... b]) = { A[a]IOS(Ala+1...b]) A[k]IOS(Ala+1...k-1] A[all Ak +1... b if a b if a Y, otherwise returns XIY. Below is another self-reduction for the ODDSORT problem. State a recursive algorithm using pseudocode for solving the ODDSORT problem based on this self-reduction pairsors(A[a], A[b]) if a b if b= a +1 if b> a+1 SOS(Ala...bl) = with A' A" A" - - - SOS(Ala... 12 A 12 +1...b] A'la...AI SOSIA'1+1...b]) SOSCA" la... 121 1A" [12 +1...b] (2+2 points) 4. Using the same reduction as in item 3 above, state a recurrence T') that expresses the worst case running time of the recursive algorithm. From this recurrence, find a tight

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

Data Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

0123814790, 9780123814791

More Books

Students also viewed these Databases questions

Question

Did you provide headings that offer structure to the information?

Answered: 1 week ago