Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please show all work and make the writing readable if youre going to handwrite. Thank you for your time. a || denotes the concatenation of

image text in transcribed

Please show all work and make the writing readable if youre going to handwrite.

Thank you for your time.

a || denotes the concatenation of lists a and B (in this order); & denotes the empty string; len(s) 2 0 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 Aa... b]; t= a+[(b-a)/3] and t2 = b-[(b-a)/3] denote the indices at one third and two thirds the way from a to 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 lsis js n 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(Aa...b]) A A[a] || OS(A[a+l...b]) A[k] || OS(A[a+l...k-1] || A[a] || A[k +1...b]) if a b if a

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

Step: 3

blur-text-image

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

Advances In Spatial And Temporal Databases 10th International Symposium Sstd 2007 Boston Ma Usa July 2007 Proceedings Lncs 4605

Authors: Dimitris Papadias ,Donghui Zhang ,George Kollios

2007th Edition

3540735399, 978-3540735397

More Books

Students also viewed these Databases questions

Question

=+ how might this lead to faster growth in productivity?

Answered: 1 week ago