Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

INSERTION-MERGE-SORT(A, p, r) if p key A[I + 1] = A[j] i = I - 1 A[i + 1] = key

ID: 3528630 • Letter: I

Question

INSERTION-MERGE-SORT(A, p, r) if p key A[I + 1] = A[j] i = I - 1 A[i + 1] = key Prove that INSERTION-MERGE-SORT sorts the input array A. Hint: use induction. Identify the best and worst case of INSERTION MERGE and compute the runtime T(n) in asymptotic notation for each. Be explicit about summing the number of iterations in the loops. Identify the best and worst case of INSERTION-MERGE-SORT and compute the runtime T(n) in asymptotic notation for each. Give the recurrence explicitly for each. Imagine that the partition in INSERTION-MERGE-SORT in two subarrays is ( ) instead of ( ). Give the recurrence and its runtime again (consider only the best case). Is INSERTION-MERGE-SORT better than INSERTION-SORT? Is it better than Merge-Sort? Consider the complexity in time and memory for each case. Give the pseudocode for an algorithm SELECTI0N-MERGE-S0RT(A, p, r) that modifies Selection- Sort (A) in the same way as Insertion-Merge-Sort modified Insertion-Sort, so that it can merge two sorted arrays. Identify its best and worst case and compute the runtime T(n) in asymptotic notation for each. Based on this, would this improve over INSERTION-MERGE-SORT? Explain.

Explanation / Answer

Hey, these slides explain the insertion sort algorithm in detail.

Cheers!

http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-046j-introduction-to-algorithms-sma-5503-fall-2005/video-lectures/lecture-1-administrivia-introduction-analysis-of-algorithms-insertion-sort-mergesort/lec1.pdf

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote