SampleMCExam3Sols - Some Sample Multiple Choice Questions...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Some Sample Multiple Choice Questions for Exam #3 Solutions 1) How many swaps are performed when the array below is sorted using a Bubble Sort? 8 7 6 5 4 3 2 1 A) 8 B) 15 C) 21 D) 28 E) NOTA The first iteration performs 7 swaps, since 8 is swapped each time. The next iteration performs 6 swaps, etc. Thus, our total is 7+6+5+4+3+2+1 = 28 swaps. 2) What is the maximum number of swaps performed by a selection sort of 50 elements? A) 49 B) 99 C) 1249 D) 1250 E) 2500 Selection Sort only makes one swap for each iteration. After 49 iterations, the last element is guaranteed to be in place as well, so this is the maximum. 3) What is the best-case run-time of Insertion Sort on n elements? A) O(lgn) B) O(n) C) O(nlgn) D) O(n 2 ) E) NOTA This is when insertion sort is run on a sorted list and each item is “looked at” once, which is O(n) time.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
contents of the array right after the 3 rd call to the Merge function? 8 3 4 6 1 7 5 2 A) 8 3 4 6 1 7 5 2 B) 1 2 3 4 5 6 7 8 C) 3 4 6 8 1 7 2 5 D) 3 4 6 8 1 2 5 7 E) NOTA The correct answer is 3 4 6 8 1 7 5 2. Basically the first three Merges
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 10

SampleMCExam3Sols - Some Sample Multiple Choice Questions...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online