batcher sorting network, n = 4

16
Batcher Sorting Network, n = 4

Upload: selma

Post on 06-Jan-2016

32 views

Category:

Documents


0 download

DESCRIPTION

Batcher Sorting Network, n = 4. Batcher Sorting Network, n = 8. n = 4. n = 4. sorted. sorted. Lemma 1. Any subsequence of a sorted sequence is a sorted sequence. 0. 0. 0. 0. 0. 1. 1. 1. 1. 1. 1. 1. 1. sorted. Lemma 2. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Batcher Sorting Network,  n  = 4

Batcher Sorting Network, n = 4

Page 2: Batcher Sorting Network,  n  = 4

n = 4

n = 4

Batcher Sorting Network, n = 8

Page 3: Batcher Sorting Network,  n  = 4

Lemma 1

Any subsequence of a sorted sequence is a sorted sequence.

00011111

00111

sorted

sorted

Page 4: Batcher Sorting Network,  n  = 4

Lemma 2

For a sorted sequence, the number of 0’s in the even subsequence is either equal to, or one greater than, the number of 0’s in the odd subsequence.

00000111

0

0

0

1

0

0

1

1

sorted

even odd

Page 5: Batcher Sorting Network,  n  = 4

denotes the the number of 0’s in y y

For two sorted sequences and : x x

11 OEOE xxxx

denotes the even subsequence of Ey y

denotes the odd subsequence of Oy y

Lemma 3

Page 6: Batcher Sorting Network,  n  = 4

Lemma 3

00000111x

0

0

0

1

Ex

0

0

1

1

Ox

00011111

x

0

0

1

1

Ex

0

1

1

1

Ox

Page 7: Batcher Sorting Network,  n  = 4

Lemma 3

1 OEO xxx

1 OEO xxx

For two sorted sequences and : x x

11 OEOE xxxx

(by Lemma 2)

(by Lemma 2)

Page 8: Batcher Sorting Network,  n  = 4

Merge Network

0x

1x

2x

3x

0x

1x

2x

3x

sorted

sorted

Merge[4]

Merge[4]

sorted

0y

1y

2y

3y

4y

5y

6y

7y

Page 9: Batcher Sorting Network,  n  = 4

Merge Network (pf.)

0x

1x

2x

3x

0x

1x

2x

3x

sorted

sorted

Merge[4]

Merge[4]

sorted

sorted

(by Lemma 1)

(by Lemma 1)

Page 10: Batcher Sorting Network,  n  = 4

Merge Network (pf.)

Merge[4]

Merge[4]

sorted

sorted

Ex

Ox

Ex

Ox

OE xx OE xx and

differ by at most 1

By Lemma 3

Page 11: Batcher Sorting Network,  n  = 4

Merge Network (pf.)

Merge[4]

Merge[4]

sorted

0y

1y

2y

3y

4y

5y

6y

7y

Ex

Ox

Ex

Ox

OE xx OE xx and

differ by at most 1

By Lemma 3

Page 12: Batcher Sorting Network,  n  = 4

Merge Network (pf.)

Merge[4]

Merge[4]

Ex

Ox

Ex

Ox

OE xx OE xx and

differ by at most 1

By Lemma 3

0

0

1

1

0

0

0

1

0

0

0

0

0

1

1

1

Page 13: Batcher Sorting Network,  n  = 4

Batcher Sorting Network

0x

1x

2x

3x

4x

Sort[4]

Sort[4]

0y

1y

2y

3y

4y

5y

6y

7y

5x

6x

7x

Merge[8] sorted

Page 14: Batcher Sorting Network,  n  = 4

Merge[4]

Batcher Sorting Network, n = 4

Sort[2]

Sort[2]

Page 15: Batcher Sorting Network,  n  = 4

Sort[4]

Sort[4]

Batcher Sorting Network, n = 8

Merge[8]

Page 16: Batcher Sorting Network,  n  = 4

Sorting Networks

Batcher

n2log 1830depth

AKS (Chvátal)

)log1(log 2

1depth 22 nn

AKS (Ajtai, Komlós, Szemerédi) Network:),(logdepth nO based on expander graphs.

AKS better for 36592n