Autigers.org These questions are from the Exam One of COMP2210-Sp2017 Course at
ID: 3824475 • Letter: A
Question
Autigers.org These questions are from the Exam One of COMP2210-Sp2017 Course at Auburn University. Please Answer them and give a short explanation if necessary. Thanks. www.yifanzhang.cn
Given the array a 66, 67, 20, 86, 55, 74, 11, 91, 43, 47 which sorting algorithm would perform the following sequence of array modifications? [66, 67, 20, 86, 55, 74, 11, 91, 43, 47] [20 66, 67, 86, 55, 74, 11, 91, 43, 47] [20 66, 67, 55, 86, 74, 11, 91, 43, 47] [20 55 66 67, 86, 74, 11, 91, 43, 47] [20 55 66, 67, 86, 11, 74, 91, 43, 47] [20 55 66 67, 86, 11, 74, 91, 43, 47] [20 55 66 67, 86, 11, 74, 91, 43, 47] [20 55 66, 67, 86, 11, 43, 47, 74, 91] [11, 20, 43, 47, 55, 66, 67, 74, 86, 91] A. selection sort B. insertion sort C. merge sort D. quicksortExplanation / Answer
Q1- The answer is insertion sort .In insertion sort every element is traversed and a sorted sub list is maintained and each position is placed in its sorted position and this is how insertion sort works.
in our ques we have
66,67,20,86,55,74,11,91,43,47 now we start
first 66 and 67 are compared they are in sorted order
now 67 and 20 are compared 20 is less then 67 so it is swapped and now again from the start 66 is compared with 20 as 20 is less than 66 so it is swapped so now after this iteration the array becomes 20,66,67,86,55,74,11,91,43,47.
similarly all the comparisions are made and the array is sorted .
so that is why this is insertion sort because it inserts the element in its proper position..
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.