Question: what is the inductive step for this problem ( mergesort ) It works Inductive hypothesis: In every the recursive call on an array of
what is the inductive step for this problem mergesort It works
Inductive hypothesis:
In every the recursive call on an array of length
at most i MERGESORT returns a sorted array."
Base case : a element
array is always sorted.
Inductive step: Need to show:
If and are sorted, then
MERGELR is sorted.
Conclusion: In the top
recursive call, MERGESORT
returns a sorted array.
Fill in the inductive step! Either do it
yourself or read it in CLRS Section
CSE LO Sorting
Assume that is a power of
for convenience.
Not technically a "loop
invariant," but a
"recursion invariant,"
that should hold at the
beginning of every
recursive call.
MERGESORTA:
lengthA
if :
return
MERGESORTA:n
MERGESORT:
return MERGELR
Formally: induction
A "loop invariant" is
something that we maintain
Loop invarianti: A :i is sorted.
at every iteration of the
algorithm.
Inductive Hypothesis:
The loop invarianti holds at the end of the iteration of the outer loop
Base case :
This logic see CLRS for
Before the algorithm starts, : is sorted.
details
Inductive step:
If the inductive hypothesis holds at step i it holds at step i
Aka, if : is sorted at step then : is sorted at step
Conclusion:
At the end of the st iteration aka at the end of the algorithm:
is sorted.
That's what we wanted!
sorted list.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
