Batcher Sorting Network, n = 4
description
Transcript of Batcher Sorting Network, n = 4
![Page 1: Batcher Sorting Network, n = 4](https://reader036.fdocuments.net/reader036/viewer/2022062723/56813b7c550346895da49330/html5/thumbnails/1.jpg)
Batcher Sorting Network, n = 4
![Page 2: Batcher Sorting Network, n = 4](https://reader036.fdocuments.net/reader036/viewer/2022062723/56813b7c550346895da49330/html5/thumbnails/2.jpg)
n = 4
n = 4
Batcher Sorting Network, n = 8
![Page 3: Batcher Sorting Network, n = 4](https://reader036.fdocuments.net/reader036/viewer/2022062723/56813b7c550346895da49330/html5/thumbnails/3.jpg)
Lemma 1
Any subsequence of a sorted sequence is a sorted sequence.
00011111
00111
sorted
sorted
![Page 4: Batcher Sorting Network, n = 4](https://reader036.fdocuments.net/reader036/viewer/2022062723/56813b7c550346895da49330/html5/thumbnails/4.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062723/56813b7c550346895da49330/html5/thumbnails/5.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062723/56813b7c550346895da49330/html5/thumbnails/6.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062723/56813b7c550346895da49330/html5/thumbnails/7.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062723/56813b7c550346895da49330/html5/thumbnails/8.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062723/56813b7c550346895da49330/html5/thumbnails/9.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062723/56813b7c550346895da49330/html5/thumbnails/10.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062723/56813b7c550346895da49330/html5/thumbnails/11.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062723/56813b7c550346895da49330/html5/thumbnails/12.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062723/56813b7c550346895da49330/html5/thumbnails/13.jpg)
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](https://reader036.fdocuments.net/reader036/viewer/2022062723/56813b7c550346895da49330/html5/thumbnails/14.jpg)
Merge[4]
Batcher Sorting Network, n = 4
Sort[2]
Sort[2]
![Page 15: Batcher Sorting Network, n = 4](https://reader036.fdocuments.net/reader036/viewer/2022062723/56813b7c550346895da49330/html5/thumbnails/15.jpg)
Sort[4]
Sort[4]
Batcher Sorting Network, n = 8
Merge[8]
![Page 16: Batcher Sorting Network, n = 4](https://reader036.fdocuments.net/reader036/viewer/2022062723/56813b7c550346895da49330/html5/thumbnails/16.jpg)
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