Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Input: data 1 : array with n integers Input: data 2 : array with n integers Input: n: size of data 1 and data 2

Input: data1: array with n integers
Input: data2: array with n integers
Input: n: size of data1 and data2
Output: array of size 2n containing all elements of data1
and data2 where
output[1]<= output[2]<=...<= output[2n] Algorithm: MysterySort
Sort data1 using SelectionSort Sort data2 using SelectionSort Append \infty to data1 and data2 output = Array(2n) left=right=1 fori=1to2ndo
if data1[left]<= data2[right] then output[i]= data1[left]
left = left +1
else
output[i]= data2[right]
right = right +1 end
end
return output 1. Prove that output[i] is less than or equal to everything in data1[left..n] and data2[right..n] after every iteration of the for loop in MysterySort.
2. Briefly argue why output[1]<= output[2] after the second iteration.

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

Database Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

More Books

Students also viewed these Databases questions