Answered step by step
Verified Expert Solution
Question
1 Approved Answer
INSERTION-MERGE-SORT A, p,r) 1 if p key Ali + 1] = Ali] 4 INSERTION-MERGE-SoRT(A,q+1,r) INSERTIONMERGE A, p,q,r) 7Ali-key MERGE(A, p.q.r) 3 let L.and n2 +
INSERTION-MERGE-SORT A, p,r) 1 if p key Ali + 1] = Ali] 4 INSERTION-MERGE-SoRT(A,q+1,r) INSERTIONMERGE A, p,q,r) 7Ali-key MERGE(A, p.q.r) 3 let L.and n2 + 4 for i= 1 to n! be new arrays -p + i-1] 10i=1 12 for k=ptor 13 i LRU A[k] = L[i] 15 16 else A = RUI 17 1. Prove that INSERTIONMERGE solves the same problem as the MERGE algorithm but works in place. Hint: use a loop invariant 2. Prove that INSERTION-MERGE-SORT sorts the input array A. Hint: use induction. INSERTION-MERGE-SORT A, p,r) 1 if p key Ali + 1] = Ali] 4 INSERTION-MERGE-SoRT(A,q+1,r) INSERTIONMERGE A, p,q,r) 7Ali-key MERGE(A, p.q.r) 3 let L.and n2 + 4 for i= 1 to n! be new arrays -p + i-1] 10i=1 12 for k=ptor 13 i LRU A[k] = L[i] 15 16 else A = RUI 17 1. Prove that INSERTIONMERGE solves the same problem as the MERGE algorithm but works in place. Hint: use a loop invariant 2. Prove that INSERTION-MERGE-SORT sorts the input array A. Hint: use induction
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