OEMergeSort - unsorted input A complete 8-input sorting...

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

Batcher’s Networks for Merging / Sorting L H max(a , b) b min(a , b) a Compare-exchange operation Building Block Comparator

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

View Full Document
L H L H L H a a a a Sorted c c c c Sorted 2x2 O-E merging Network # of comparators = 3 depth, delay or time = 2 ( length of the longest path from input to an output )
L H L H L H 36 14 7 1 12 7 3 1 4x4 O-E merging Network # of comparators = (3 + 3) + 3 = 9 time required = 2 + 1 = 3 L H L H L H 25 18 12 3 36 25 18 14 L H L H L H Sorted Sorted 1 3 7

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

View Full Document
L H L H L H L H L H L H L H 4x4 Merging Network 4x4 Merging Network odd even 8x8 Batcher’s Odd-Even Merging Network # of comparators = 2 * 9 + 7 = 25 time required = 3 + 1 = 4 x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 y 1 y 2 y 3 y 4 y 5 y 6 y 7 y 8 z 1 z 2 z 3 z 4 z 5 z 6 z 7 z 8 z 9 z 10 z 11 z 12 z 13 z 14 z 15 z 16 Sorted Sorted
L H L H L H L H (m/2)x(m/2) Merging Network (m/2)x(m/2) Merging Network odd even a 1 a 2 a 3 a 4 a m b 1 b 2 b 3 b 4 b m-1 b m e 1 e 2 z 3 e 4 e 5 e 2i e 2i+1 e 2m -1 e 2m c 1 c 2 d 1 d 2 d m c m c i+1 d i Recursive Construction B sorted A sorted

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

View Full Document
What About Sorting? Sort by repeated mergers Merger Sorted Output Size 1x1 2 2x2 4 4x4 8 ( n /2)x( n /2) n
L H L H 2x2 merg. netw. L H L H 2x2 merg. netw. 4x4 merg. netw. sorted output

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: unsorted input A complete 8-input sorting network Odd-Even Recursive Constrution of an Odd-Even Sorter Length m Sorter Length m Sorter m x m O-E Merger unsorted n / 2 unsorted n / 2 sorted n Sorter Depth D s ( n ) = D s ( n /2) + D m ( n ) D s (2) = 1 D s ( n ) = ((1 + log n ) log n ) / 2 = O ( log 2 n ) log n Odd-Even Merge / Sort ) 1 ( ) 1 )(log (log 4 1 ) 2 ( and ) ( ) 2 ( 2 ) ( 2 log ) log 1 ( ) ( 1 ) 2 ( and ) ( ) 2 ( ) ( 1 2 log 2 ) ( 1 ) 2 ( and 1 2 ) 2 ( 2 ) ( log ) ( 1 ) 2 ( and 1 ) 2 ( ) (-+-⇒ = + = + = ⇒ = + = + = ⇒ =-+ = = ⇒ = + = n n n n C n C n C n C n n n D D n D n D n D n n n C C n n C n C n n D D n D n D S M S S S S M S S M M M M M M M M...
View Full Document

{[ snackBarMessage ]}

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern