Discrete Mathematics with Graph Theory (3rd Edition) 237

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

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

View Full Document Right Arrow Icon
Section 8.3 235 16. [BB] Sort the list into increasing order al ~ a2 ~ ... ~ an. If n = 2m + 1 is odd, the median is am; if n = 2m is even, the median is ~ (am + am + 1). Since determining the parity of n adds only another operation, the complexity of this algorithm is the complexity of the sort, at best 0 ( n log n). 17. (a) [BB] Here's the bubble sort. k = 7: a,b,c,d,u,v,w,x ---+ a,b,c,d,u,v,w,x ---+ a,c,b,d,u,v,w,x ---+ a, c, d, b, u, v, w, x ---+ a,c, d, u, b, v, w, x - ---+ a, c, d, u, b, v, w, x ---+ a, c, d, u, b, v, w, x k = 6: a,c,d,u,b,v,x,w ---+ a,c,d,u,b,v,x,w ---+ a,d,c,u,b,v,x,w ---+ a, d, u, c, b, v, x, w ---+ a,d, u, c, b, v, x, w ---+ a-;tI:u, c, b, v, x, w k = 5: a,d,u,c,b,x,v,w ---+ d,a,u,c,b,x,v,w ---+ d,a,u,c,b,x,v,w ---+ d, a, u, c, b, x, v, w ---+ d, a, u, c, b, x, v, w - k = 4: d, a, u, c, x, b, v, w ---+ d, a, u, c, x, b, v, w ---+ d, a, u, c, x, b, v, w ---+ d,a,u,c,x,b,v,w - - k = 3: d,a,u,c,x,b,v,w ---+ d,a,u,c,x,b,v,w ---+ d,a,u,c,x,b,v,w k = 2: d, a, u, c, x,
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Ask a homework question - tutors are online