SampleMCExam3Sols

# SampleMCExam3Sols - Some Sample Multiple Choice Questions...

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

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.

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

View Full Document
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
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 09/22/2010 for the course EECS COP 3502 taught by Professor Guha during the Spring '09 term at University of Central Florida.

### 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
Ask a homework question - tutors are online