Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!