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

How many comparisons and interchanges (in terms of Tile si/e a) are performed by

ID: 3687301 • Letter: H

Question

How many comparisons and interchanges (in terms of Tile si/e a) are performed by (a) Simple insertion sort and (b) Shell Sort using increments 2 and 1 for the following files: A sorted file A file that K sorted in reverse order (that is, from largest to smallest) A file in which |0|, x|2|, x|4|... are the smallest elements in sorted order, and in sshich x| 11|. x131. x|5|... and the largest elements in sorted order Determine which of the following sorts is most efficient: simple insertion sort straight selection sort bubble sort Determine the number of comparisons (as a function of n and m) that are performed in merging two ordered files a and b of sizes n and m. respectisels. by the merge method presented in the lecture, on each of the following sets of ordered files: m=n and a|i| lessthan b|i| lessthan  a|i+l| m-n and a|n| lessthan  b|l| | i | refers the value in position i of file a. etc. Determine the number of comparisons (as a function of n and m) that are performed in merging two ordered files a and b of sizes n and m. respectisels. by the merge method presented in the lecture, on each of the following sets of ordered files: m-n and a|n/2| lessthan  b|l| lessthan  b|m| lessthan  a|(n'2)+l| m=l and b|l| lessthan  a|l| m-1 and a|n|

Explanation / Answer

Simple Insertion sort

simple insertion

straight selection

            Best case: O(n^2) performs less than insertion – ruled out = eliminated

bubble best = O(n^2) = lesser performance than insertion

hence simple insertion sort is the most efficient of the 3 sorts compared

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