Discrete Mathematics with Graph Theory (3rd Edition) 236

# Discrete Mathematics with Graph Theory (3rd Edition) 236 -...

This preview shows page 1. Sign up to view the full content.

234 15. Solutions to Exercises k = 2: 2,2,3,4,5,5,7 k = 1: ~,3,4,5,5, 7 ~ 2,2,3,4,5,5,7 ~ 2,2,3,4,5,5,7 This required a total of 6 + 5 + 4 + 3 + 2 + 1 = (6)P) = 21 comparisons. (b) Here's the merge sort. Step 2: 7; 2; 2; 5; 3; 5; 4; Step 3: 2,7; 2,5; 3,5; 4 Step 3: 2,2,5,7; 3,4,5 Step 3: 2,2,3,4,5,5,7 Merging two lists of length 1 to one of length 2 requires 1 + 1-1 = 1 comparison. Thus, the initial merging of seven lists of length 1 to three of length 2 and one of length 1 required 1 + 1 + 1 = 3 comparisons. The merging of three lists of length 2 and one of length 1 to one list of length 4 and another of length 3 required (2 + 2 - 1) + (2 + 1 - 1) = 5 comparisons. The final merging required 4 + 3 - 1 = 6 comparisons. The total is 3 + 5 + 6 = 14 comparisons. (a) Here's the bubble sort: k = 7: 10,11,15,3,18,14,7,1 k = 6: 10,11,3,15,14,7,1,18 ~ 10,11,15,3,18,14,7,1 ~ 10,11,3,15,14,7,1,18 ~ 10,11,15,3,18,14,7,1 ~ 10,3,11,15,14,7,1,18 ~ 10,11,3,15,18,14,7,1 ~ 10,3,11,15,14,7,1,18 ~ 10,11,3,15,18,14,7,1
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 11/08/2010 for the course MATH discrete m taught by Professor Any during the Summer '10 term at FSU.

Ask a homework question - tutors are online