Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 7 25 pts Answer the following questions about the RecMysterySort algorithm below. Input: A: array with n real numbers Input: n: size of data
Question 7 25 pts Answer the following questions about the RecMysterySort algorithm below. Input: A: array with n real numbers Input: n: size of data Output permutation of data such that A[1] = A[2] S...S A[n] 1 Algorithm: RecMystery Sort 2 if n = 2 then 3 if A[1] > A[2] then 4 Swap A[1] and A[2]: 5 end 6 else if n > 1 then 7 first = [1/4]: 8 third = n-first; 9 RecMystery Sort(A[1. third]): 10 RecMystery Sort(A[first. n): 11 RecMysterySort(A[1..third]): 12 end 13 return A: a) (10 points) Write a recurrence that describes the worst case time complexity of RecMysterySort. Show your work. b) [5 points) Find the worst case time complexity of RecMysterySort. Show your work. c) (10 points) How does RecMysterySort compare to MergeSort and Insertion Sort? Justify your answer. A table of approximate log values appears below. 10g, (3) log: (1) log:(:) log2 (4) log, () log(?) log4 (3) log (4) log; (3) log? (4) 3.819 4.819 -3.819 -4.819 0.262 -0.262 -0.208 1.262 0.792 0.208 Table Edit View Insert Format Tools Question 7 25 pts Answer the following questions about the RecMysterySort algorithm below. Input: A: array with n real numbers Input: n: size of data Output permutation of data such that A[1] = A[2] S...S A[n] 1 Algorithm: RecMystery Sort 2 if n = 2 then 3 if A[1] > A[2] then 4 Swap A[1] and A[2]: 5 end 6 else if n > 1 then 7 first = [1/4]: 8 third = n-first; 9 RecMystery Sort(A[1. third]): 10 RecMystery Sort(A[first. n): 11 RecMysterySort(A[1..third]): 12 end 13 return A: a) (10 points) Write a recurrence that describes the worst case time complexity of RecMysterySort. Show your work. b) [5 points) Find the worst case time complexity of RecMysterySort. Show your work. c) (10 points) How does RecMysterySort compare to MergeSort and Insertion Sort? Justify your answer. A table of approximate log values appears below. 10g, (3) log: (1) log:(:) log2 (4) log, () log(?) log4 (3) log (4) log; (3) log? (4) 3.819 4.819 -3.819 -4.819 0.262 -0.262 -0.208 1.262 0.792 0.208 Table Edit View Insert Format Tools
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started