Sorting networks Lecture 24 November 19, 2015 Sariel (UIUC) New - - PowerPoint PPT Presentation

sorting networks
SMART_READER_LITE
LIVE PREVIEW

Sorting networks Lecture 24 November 19, 2015 Sariel (UIUC) New - - PowerPoint PPT Presentation

NEW CS 473: Theory II, Fall 2015 Sorting networks Lecture 24 November 19, 2015 Sariel (UIUC) New CS473 1 Fall 2015 1 / 35 24.1: Model of Computation Sariel (UIUC) New CS473 2 Fall 2015 2 / 35 Model of Computation Q: Perform a


slide-1
SLIDE 1

NEW CS 473: Theory II, Fall 2015

Sorting networks

Lecture 24

November 19, 2015

Sariel (UIUC) New CS473 1 Fall 2015 1 / 35

slide-2
SLIDE 2

24.1: Model of Computation

Sariel (UIUC) New CS473 2 Fall 2015 2 / 35

slide-3
SLIDE 3

Model of Computation

1

Q: Perform a computational task considerably faster by using a different architecture? Yep.

2

Spaghetti sort!

Sariel (UIUC) New CS473 3 Fall 2015 3 / 35

slide-4
SLIDE 4

Model of Computation

1

Q: Perform a computational task considerably faster by using a different architecture? Yep.

2

Spaghetti sort!

Sariel (UIUC) New CS473 3 Fall 2015 3 / 35

slide-5
SLIDE 5

Model of Computation

1

Q: Perform a computational task considerably faster by using a different architecture? Yep.

2

Spaghetti sort!

Sariel (UIUC) New CS473 3 Fall 2015 3 / 35

slide-6
SLIDE 6

Spaghetti

Sariel (UIUC) New CS473 4 Fall 2015 4 / 35

slide-7
SLIDE 7

Spaghetti

Pastafarianism

Sariel (UIUC) New CS473 4 Fall 2015 4 / 35

slide-8
SLIDE 8

Spaghetti

Sariel (UIUC) New CS473 4 Fall 2015 4 / 35

slide-9
SLIDE 9

Spaghetti

Sariel (UIUC) New CS473 4 Fall 2015 4 / 35

slide-10
SLIDE 10

Spaghetti

The spaghetti tree hoax was a three-minute hoax report broadcast on April Fools’ Day 1957 by the BBC current-affairs programme Panorama, purportedly showing a family in southern Switzerland harvesting spaghetti from the family ”spaghetti tree”. At the time spaghetti was relatively little-known in the UK, so that many Britons were unaware that spaghetti is made from wheat flour and water; a number of viewers afterwards contacted the BBC for advice on growing their own spaghetti trees. Decades later CNN called this broadcast ”the biggest hoax that any reputable news establishment ever pulled.”

Sariel (UIUC) New CS473 4 Fall 2015 4 / 35

slide-11
SLIDE 11

Spaghetti sort

1

Input: S = {s1, . . . , sn} ⊆ [1, 2].

2

Have much Spaghetti (this are longish and very narrow tubes of pasta).

3

cut ith piece to be of length si, for i = 1, . . . , n.

4

take all these pieces of pasta in your hand..

5

make them stand up vertically, with their bottom end lying on a horizontal surface

6

lower your handle till it hit the first (i.e., tallest) piece of pasta.

7

Take it out, measure it height, write down its number

8

and continue in this fashion till done.

9

Linear time sorting algorithm.

10 ...but sorting takes Ω(n log n) time. Sariel (UIUC) New CS473 5 Fall 2015 5 / 35

slide-12
SLIDE 12

Spaghetti sort

1

Input: S = {s1, . . . , sn} ⊆ [1, 2].

2

Have much Spaghetti (this are longish and very narrow tubes of pasta).

3

cut ith piece to be of length si, for i = 1, . . . , n.

4

take all these pieces of pasta in your hand..

5

make them stand up vertically, with their bottom end lying on a horizontal surface

6

lower your handle till it hit the first (i.e., tallest) piece of pasta.

7

Take it out, measure it height, write down its number

8

and continue in this fashion till done.

9

Linear time sorting algorithm.

10 ...but sorting takes Ω(n log n) time. Sariel (UIUC) New CS473 5 Fall 2015 5 / 35

slide-13
SLIDE 13

Spaghetti sort

1

Input: S = {s1, . . . , sn} ⊆ [1, 2].

2

Have much Spaghetti (this are longish and very narrow tubes of pasta).

3

cut ith piece to be of length si, for i = 1, . . . , n.

4

take all these pieces of pasta in your hand..

5

make them stand up vertically, with their bottom end lying on a horizontal surface

6

lower your handle till it hit the first (i.e., tallest) piece of pasta.

7

Take it out, measure it height, write down its number

8

and continue in this fashion till done.

9

Linear time sorting algorithm.

10 ...but sorting takes Ω(n log n) time. Sariel (UIUC) New CS473 5 Fall 2015 5 / 35

slide-14
SLIDE 14

Spaghetti sort

1

Input: S = {s1, . . . , sn} ⊆ [1, 2].

2

Have much Spaghetti (this are longish and very narrow tubes of pasta).

3

cut ith piece to be of length si, for i = 1, . . . , n.

4

take all these pieces of pasta in your hand..

5

make them stand up vertically, with their bottom end lying on a horizontal surface

6

lower your handle till it hit the first (i.e., tallest) piece of pasta.

7

Take it out, measure it height, write down its number

8

and continue in this fashion till done.

9

Linear time sorting algorithm.

10 ...but sorting takes Ω(n log n) time. Sariel (UIUC) New CS473 5 Fall 2015 5 / 35

slide-15
SLIDE 15

Spaghetti sort

1

Input: S = {s1, . . . , sn} ⊆ [1, 2].

2

Have much Spaghetti (this are longish and very narrow tubes of pasta).

3

cut ith piece to be of length si, for i = 1, . . . , n.

4

take all these pieces of pasta in your hand..

5

make them stand up vertically, with their bottom end lying on a horizontal surface

6

lower your handle till it hit the first (i.e., tallest) piece of pasta.

7

Take it out, measure it height, write down its number

8

and continue in this fashion till done.

9

Linear time sorting algorithm.

10 ...but sorting takes Ω(n log n) time. Sariel (UIUC) New CS473 5 Fall 2015 5 / 35

slide-16
SLIDE 16

Spaghetti sort

1

Input: S = {s1, . . . , sn} ⊆ [1, 2].

2

Have much Spaghetti (this are longish and very narrow tubes of pasta).

3

cut ith piece to be of length si, for i = 1, . . . , n.

4

take all these pieces of pasta in your hand..

5

make them stand up vertically, with their bottom end lying on a horizontal surface

6

lower your handle till it hit the first (i.e., tallest) piece of pasta.

7

Take it out, measure it height, write down its number

8

and continue in this fashion till done.

9

Linear time sorting algorithm.

10 ...but sorting takes Ω(n log n) time. Sariel (UIUC) New CS473 5 Fall 2015 5 / 35

slide-17
SLIDE 17

Spaghetti sort

1

Input: S = {s1, . . . , sn} ⊆ [1, 2].

2

Have much Spaghetti (this are longish and very narrow tubes of pasta).

3

cut ith piece to be of length si, for i = 1, . . . , n.

4

take all these pieces of pasta in your hand..

5

make them stand up vertically, with their bottom end lying on a horizontal surface

6

lower your handle till it hit the first (i.e., tallest) piece of pasta.

7

Take it out, measure it height, write down its number

8

and continue in this fashion till done.

9

Linear time sorting algorithm.

10 ...but sorting takes Ω(n log n) time. Sariel (UIUC) New CS473 5 Fall 2015 5 / 35

slide-18
SLIDE 18

Spaghetti sort

1

Input: S = {s1, . . . , sn} ⊆ [1, 2].

2

Have much Spaghetti (this are longish and very narrow tubes of pasta).

3

cut ith piece to be of length si, for i = 1, . . . , n.

4

take all these pieces of pasta in your hand..

5

make them stand up vertically, with their bottom end lying on a horizontal surface

6

lower your handle till it hit the first (i.e., tallest) piece of pasta.

7

Take it out, measure it height, write down its number

8

and continue in this fashion till done.

9

Linear time sorting algorithm.

10 ...but sorting takes Ω(n log n) time. Sariel (UIUC) New CS473 5 Fall 2015 5 / 35

slide-19
SLIDE 19

Spaghetti sort

1

Input: S = {s1, . . . , sn} ⊆ [1, 2].

2

Have much Spaghetti (this are longish and very narrow tubes of pasta).

3

cut ith piece to be of length si, for i = 1, . . . , n.

4

take all these pieces of pasta in your hand..

5

make them stand up vertically, with their bottom end lying on a horizontal surface

6

lower your handle till it hit the first (i.e., tallest) piece of pasta.

7

Take it out, measure it height, write down its number

8

and continue in this fashion till done.

9

Linear time sorting algorithm.

10 ...but sorting takes Ω(n log n) time. Sariel (UIUC) New CS473 5 Fall 2015 5 / 35

slide-20
SLIDE 20

Spaghetti sort

1

Input: S = {s1, . . . , sn} ⊆ [1, 2].

2

Have much Spaghetti (this are longish and very narrow tubes of pasta).

3

cut ith piece to be of length si, for i = 1, . . . , n.

4

take all these pieces of pasta in your hand..

5

make them stand up vertically, with their bottom end lying on a horizontal surface

6

lower your handle till it hit the first (i.e., tallest) piece of pasta.

7

Take it out, measure it height, write down its number

8

and continue in this fashion till done.

9

Linear time sorting algorithm.

10 ...but sorting takes Ω(n log n) time. Sariel (UIUC) New CS473 5 Fall 2015 5 / 35

slide-21
SLIDE 21

What is going on?

1

Faster algorithm achieved by changing the computation model.

2

allowed new “strange” operations (cutting a piece of pasta into a certain length, picking the longest one in constant time, and measuring the length of a pasta piece in constant time)

3

Using these operations we can sort in linear time.

4

So, are there other useful computation models?

Sariel (UIUC) New CS473 6 Fall 2015 6 / 35

slide-22
SLIDE 22

What is going on?

1

Faster algorithm achieved by changing the computation model.

2

allowed new “strange” operations (cutting a piece of pasta into a certain length, picking the longest one in constant time, and measuring the length of a pasta piece in constant time)

3

Using these operations we can sort in linear time.

4

So, are there other useful computation models?

Sariel (UIUC) New CS473 6 Fall 2015 6 / 35

slide-23
SLIDE 23

What is going on?

1

Faster algorithm achieved by changing the computation model.

2

allowed new “strange” operations (cutting a piece of pasta into a certain length, picking the longest one in constant time, and measuring the length of a pasta piece in constant time)

3

Using these operations we can sort in linear time.

4

So, are there other useful computation models?

Sariel (UIUC) New CS473 6 Fall 2015 6 / 35

slide-24
SLIDE 24

What is going on?

1

Faster algorithm achieved by changing the computation model.

2

allowed new “strange” operations (cutting a piece of pasta into a certain length, picking the longest one in constant time, and measuring the length of a pasta piece in constant time)

3

Using these operations we can sort in linear time.

4

So, are there other useful computation models?

Sariel (UIUC) New CS473 6 Fall 2015 6 / 35

slide-25
SLIDE 25

What is going on?

1

Faster algorithm achieved by changing the computation model.

2

allowed new “strange” operations (cutting a piece of pasta into a certain length, picking the longest one in constant time, and measuring the length of a pasta piece in constant time)

3

Using these operations we can sort in linear time.

4

So, are there other useful computation models?

Sariel (UIUC) New CS473 6 Fall 2015 6 / 35

slide-26
SLIDE 26

Circuits are fast...

1

Computing the following circuit naively takes 8 units of time.

2

Use parallelism!

3

Circuits are really parallel...

4

Sorting numbers with circuits?

5

Q: Can sort in sublinear time by allowing parallel comparisons?

Sariel (UIUC) New CS473 7 Fall 2015 7 / 35

slide-27
SLIDE 27

Circuits are fast...

1

Computing the following circuit naively takes 8 units of time.

2

Use parallelism!

3

Circuits are really parallel...

4

Sorting numbers with circuits?

5

Q: Can sort in sublinear time by allowing parallel comparisons?

Sariel (UIUC) New CS473 7 Fall 2015 7 / 35

slide-28
SLIDE 28

Circuits are fast...

1

Computing the following circuit naively takes 8 units of time.

2

Use parallelism!

3

Circuits are really parallel...

4

Sorting numbers with circuits?

5

Q: Can sort in sublinear time by allowing parallel comparisons?

Sariel (UIUC) New CS473 7 Fall 2015 7 / 35

slide-29
SLIDE 29

Circuits are fast...

1

Computing the following circuit naively takes 8 units of time.

2

Use parallelism! 4 time units!

3

Circuits are really parallel...

4

Sorting numbers with circuits?

5

Q: Can sort in sublinear time by allowing parallel comparisons?

Sariel (UIUC) New CS473 7 Fall 2015 7 / 35

slide-30
SLIDE 30

Circuits are fast...

1

Computing the following circuit naively takes 8 units of time.

2

Use parallelism! 4 time units!

3

Circuits are really parallel...

4

Sorting numbers with circuits?

5

Q: Can sort in sublinear time by allowing parallel comparisons?

Sariel (UIUC) New CS473 7 Fall 2015 7 / 35

slide-31
SLIDE 31

Circuits are fast...

1

Computing the following circuit naively takes 8 units of time.

2

Use parallelism! 4 time units!

3

Circuits are really parallel...

4

Sorting numbers with circuits?

5

Q: Can sort in sublinear time by allowing parallel comparisons?

Sariel (UIUC) New CS473 7 Fall 2015 7 / 35

slide-32
SLIDE 32

24.2: Sorting with a circuit – a naive solution

Sariel (UIUC) New CS473 8 Fall 2015 8 / 35

slide-33
SLIDE 33

Sorting with a circuit – a naive solution

1

comparator gate:

Comparator

x y y′ = max(x, y) x′ = min(x, y)

2

Draw it as:

Sariel (UIUC) New CS473 9 Fall 2015 9 / 35

slide-34
SLIDE 34

Sorting with a circuit – a naive solution

1

comparator gate:

Comparator

x y y′ = max(x, y) x′ = min(x, y)

2

Draw it as:

Sariel (UIUC) New CS473 9 Fall 2015 9 / 35

slide-35
SLIDE 35

Sorting with a circuit – a naive solution

1

comparator gate:

Comparator

x y y′ = max(x, y) x′ = min(x, y)

2

Draw it as: y x′ = min(x, y) y′ = max(x, y) x

Sariel (UIUC) New CS473 9 Fall 2015 9 / 35

slide-36
SLIDE 36

Sorting network - an example

Sariel (UIUC) New CS473 10 Fall 2015 10 / 35

slide-37
SLIDE 37

How to draw a circuit...

1 wires: horizontal lines 2 gates: vertical segments (i.e.,

gates) connecting lines.

3

Inputs arrive the wires from left.

4

Output on the right side of wires.

5

largest number is output on the bottom line.

6

Sorting algorithms = ⇒ sorting circuits.

Sariel (UIUC) New CS473 11 Fall 2015 11 / 35

slide-38
SLIDE 38

How to draw a circuit...

1 wires: horizontal lines 2 gates: vertical segments (i.e.,

gates) connecting lines.

3

Inputs arrive the wires from left.

4

Output on the right side of wires.

5

largest number is output on the bottom line.

6

Sorting algorithms = ⇒ sorting circuits.

Sariel (UIUC) New CS473 11 Fall 2015 11 / 35

slide-39
SLIDE 39

How to draw a circuit...

1 wires: horizontal lines 2 gates: vertical segments (i.e.,

gates) connecting lines.

3

Inputs arrive the wires from left.

4

Output on the right side of wires.

5

largest number is output on the bottom line.

6

Sorting algorithms = ⇒ sorting circuits.

Sariel (UIUC) New CS473 11 Fall 2015 11 / 35

slide-40
SLIDE 40

How to draw a circuit...

1 wires: horizontal lines 2 gates: vertical segments (i.e.,

gates) connecting lines.

3

Inputs arrive the wires from left.

4

Output on the right side of wires.

5

largest number is output on the bottom line.

6

Sorting algorithms = ⇒ sorting circuits.

Sariel (UIUC) New CS473 11 Fall 2015 11 / 35

slide-41
SLIDE 41

How to draw a circuit...

1 wires: horizontal lines 2 gates: vertical segments (i.e.,

gates) connecting lines.

3

Inputs arrive the wires from left.

4

Output on the right side of wires.

5

largest number is output on the bottom line.

6

Sorting algorithms = ⇒ sorting circuits.

Sariel (UIUC) New CS473 11 Fall 2015 11 / 35

slide-42
SLIDE 42

How to draw a circuit...

1 wires: horizontal lines 2 gates: vertical segments (i.e.,

gates) connecting lines.

3

Inputs arrive the wires from left.

4

Output on the right side of wires.

5

largest number is output on the bottom line.

6

Sorting algorithms = ⇒ sorting circuits.

Sariel (UIUC) New CS473 11 Fall 2015 11 / 35

slide-43
SLIDE 43

Definitions

Definition

A comparison network is a DAG, with n inputs and n outputs, where each gate has two inputs and two outputs.

Definition

depth of a wire is 0 at input. For gate with two inputs of depth d1 and d2 the depth on the output wire is 1 + max(d1, d2). depth of comparison network is maximum depth of an output wire.

Definition

sorting network: comparison network such that for any input, the

  • utput is monotonically sorted.

size: sorting network is number of gates. running time of sorting network is its depth.

Sariel (UIUC) New CS473 12 Fall 2015 12 / 35

slide-44
SLIDE 44

Definitions

Definition

A comparison network is a DAG, with n inputs and n outputs, where each gate has two inputs and two outputs.

Definition

depth of a wire is 0 at input. For gate with two inputs of depth d1 and d2 the depth on the output wire is 1 + max(d1, d2). depth of comparison network is maximum depth of an output wire.

Definition

sorting network: comparison network such that for any input, the

  • utput is monotonically sorted.

size: sorting network is number of gates. running time of sorting network is its depth.

Sariel (UIUC) New CS473 12 Fall 2015 12 / 35

slide-45
SLIDE 45

Definitions

Definition

A comparison network is a DAG, with n inputs and n outputs, where each gate has two inputs and two outputs.

Definition

depth of a wire is 0 at input. For gate with two inputs of depth d1 and d2 the depth on the output wire is 1 + max(d1, d2). depth of comparison network is maximum depth of an output wire.

Definition

sorting network: comparison network such that for any input, the

  • utput is monotonically sorted.

size: sorting network is number of gates. running time of sorting network is its depth.

Sariel (UIUC) New CS473 12 Fall 2015 12 / 35

slide-46
SLIDE 46

Sorting network based on insertion sort

1

Inner loop of insertion sort is:

2

Insertion sort as a network:

Sariel (UIUC) New CS473 13 Fall 2015 13 / 35

slide-47
SLIDE 47

Sorting network based on insertion sort

1

Inner loop of insertion sort is:

2

Insertion sort as a network:

Sariel (UIUC) New CS473 13 Fall 2015 13 / 35

slide-48
SLIDE 48

Sorting network based on insertion sort

1 2 3 4 5 6 7 8 9

(i) (ii)

Lemma

The sorting network based on insertion sort has O(n2) gates, and requires 2n − 1 time units to sort n numbers.

Sariel (UIUC) New CS473 14 Fall 2015 14 / 35

slide-49
SLIDE 49

Sorting network based on insertion sort

1 2 3 4 5 6 7 8 9

(i) (ii)

Lemma

The sorting network based on insertion sort has O(n2) gates, and requires 2n − 1 time units to sort n numbers.

Sariel (UIUC) New CS473 14 Fall 2015 14 / 35

slide-50
SLIDE 50

24.3: The Zero-One Principle

Sariel (UIUC) New CS473 15 Fall 2015 15 / 35

slide-51
SLIDE 51

Converting a sequence into a binary sequence

2 4 6 8 10 A B C D E F G H I x

Sariel (UIUC) New CS473 16 Fall 2015 16 / 35

slide-52
SLIDE 52

Converting a sequence into a binary sequence

2 4 6 8 10 A B C D E F G H I x

Sariel (UIUC) New CS473 16 Fall 2015 16 / 35

slide-53
SLIDE 53

Converting a sequence into a binary sequence

2 4 6 8 10 A B C D E F G H I x

Sariel (UIUC) New CS473 16 Fall 2015 16 / 35

slide-54
SLIDE 54

Converting a sequence into a binary sequence

Sariel (UIUC) New CS473 16 Fall 2015 16 / 35

slide-55
SLIDE 55

Converting a sequence into a binary sequence 1 1 1 1

Sariel (UIUC) New CS473 16 Fall 2015 16 / 35

slide-56
SLIDE 56

24.3.1: The zero-one principle

Sariel (UIUC) New CS473 17 Fall 2015 17 / 35

slide-57
SLIDE 57

The Zero-One Principle

Definition

zero-one principle states that if a comparison network sort correctly all binary inputs (∀ input is 0 or 1) then it sorts correctly all inputs (input is real number). Need to prove the zero-one principle.

Lemma

A comparison network transforms input sequence a = a1, a2, . . . , an = ⇒ b = b1, b2, . . . , bn Then for any monotonically increasing function f, the network transforms f(a) =

  • f(a1), . . . , f(an)
  • =

⇒ f(b) =

  • f(b1), . . . , f(bn)
  • Sariel (UIUC)

New CS473 18 Fall 2015 18 / 35

slide-58
SLIDE 58

The Zero-One Principle

Definition

zero-one principle states that if a comparison network sort correctly all binary inputs (∀ input is 0 or 1) then it sorts correctly all inputs (input is real number). Need to prove the zero-one principle.

Lemma

A comparison network transforms input sequence a = a1, a2, . . . , an = ⇒ b = b1, b2, . . . , bn Then for any monotonically increasing function f, the network transforms f(a) =

  • f(a1), . . . , f(an)
  • =

⇒ f(b) =

  • f(b1), . . . , f(bn)
  • Sariel (UIUC)

New CS473 18 Fall 2015 18 / 35

slide-59
SLIDE 59

The Zero-One Principle

Definition

zero-one principle states that if a comparison network sort correctly all binary inputs (∀ input is 0 or 1) then it sorts correctly all inputs (input is real number). Need to prove the zero-one principle.

Lemma

A comparison network transforms input sequence a = a1, a2, . . . , an = ⇒ b = b1, b2, . . . , bn Then for any monotonically increasing function f, the network transforms f(a) =

  • f(a1), . . . , f(an)
  • =

⇒ f(b) =

  • f(b1), . . . , f(bn)
  • Sariel (UIUC)

New CS473 18 Fall 2015 18 / 35

slide-60
SLIDE 60

Proof

1

Induction on number of comparators.

2

Consider a comparator with inputs x and y, and outputs x′ = min(x, y) and y′ = max(x, y).

3

If f(x) = f(y) then the claim trivially holds.

4

If f(x) < f(y) then clearly max(f(x), f(y)) = f(max(x, y)) and min(f(x), f(y)) = f(min(x, y)), since f(·) is monotonically increasing.

5

x, y, for x < y, we have output x, y.

6

Input: f(x), f(y) = ⇒ output is f(x), f(y).

7

Similarly, if x > y, the output is y, x. In this case, for the input f(x), f(y) the output is f(y), f(x). This establish the claim for a single comparator.

Sariel (UIUC) New CS473 19 Fall 2015 19 / 35

slide-61
SLIDE 61

Proof

1

Induction on number of comparators.

2

Consider a comparator with inputs x and y, and outputs x′ = min(x, y) and y′ = max(x, y).

3

If f(x) = f(y) then the claim trivially holds.

4

If f(x) < f(y) then clearly max(f(x), f(y)) = f(max(x, y)) and min(f(x), f(y)) = f(min(x, y)), since f(·) is monotonically increasing.

5

x, y, for x < y, we have output x, y.

6

Input: f(x), f(y) = ⇒ output is f(x), f(y).

7

Similarly, if x > y, the output is y, x. In this case, for the input f(x), f(y) the output is f(y), f(x). This establish the claim for a single comparator.

Sariel (UIUC) New CS473 19 Fall 2015 19 / 35

slide-62
SLIDE 62

Proof

1

Induction on number of comparators.

2

Consider a comparator with inputs x and y, and outputs x′ = min(x, y) and y′ = max(x, y).

3

If f(x) = f(y) then the claim trivially holds.

4

If f(x) < f(y) then clearly max(f(x), f(y)) = f(max(x, y)) and min(f(x), f(y)) = f(min(x, y)), since f(·) is monotonically increasing.

5

x, y, for x < y, we have output x, y.

6

Input: f(x), f(y) = ⇒ output is f(x), f(y).

7

Similarly, if x > y, the output is y, x. In this case, for the input f(x), f(y) the output is f(y), f(x). This establish the claim for a single comparator.

Sariel (UIUC) New CS473 19 Fall 2015 19 / 35

slide-63
SLIDE 63

Proof

1

Induction on number of comparators.

2

Consider a comparator with inputs x and y, and outputs x′ = min(x, y) and y′ = max(x, y).

3

If f(x) = f(y) then the claim trivially holds.

4

If f(x) < f(y) then clearly max(f(x), f(y)) = f(max(x, y)) and min(f(x), f(y)) = f(min(x, y)), since f(·) is monotonically increasing.

5

x, y, for x < y, we have output x, y.

6

Input: f(x), f(y) = ⇒ output is f(x), f(y).

7

Similarly, if x > y, the output is y, x. In this case, for the input f(x), f(y) the output is f(y), f(x). This establish the claim for a single comparator.

Sariel (UIUC) New CS473 19 Fall 2015 19 / 35

slide-64
SLIDE 64

Proof

1

Induction on number of comparators.

2

Consider a comparator with inputs x and y, and outputs x′ = min(x, y) and y′ = max(x, y).

3

If f(x) = f(y) then the claim trivially holds.

4

If f(x) < f(y) then clearly max(f(x), f(y)) = f(max(x, y)) and min(f(x), f(y)) = f(min(x, y)), since f(·) is monotonically increasing.

5

x, y, for x < y, we have output x, y.

6

Input: f(x), f(y) = ⇒ output is f(x), f(y).

7

Similarly, if x > y, the output is y, x. In this case, for the input f(x), f(y) the output is f(y), f(x). This establish the claim for a single comparator.

Sariel (UIUC) New CS473 19 Fall 2015 19 / 35

slide-65
SLIDE 65

Proof

1

Induction on number of comparators.

2

Consider a comparator with inputs x and y, and outputs x′ = min(x, y) and y′ = max(x, y).

3

If f(x) = f(y) then the claim trivially holds.

4

If f(x) < f(y) then clearly max(f(x), f(y)) = f(max(x, y)) and min(f(x), f(y)) = f(min(x, y)), since f(·) is monotonically increasing.

5

x, y, for x < y, we have output x, y.

6

Input: f(x), f(y) = ⇒ output is f(x), f(y).

7

Similarly, if x > y, the output is y, x. In this case, for the input f(x), f(y) the output is f(y), f(x). This establish the claim for a single comparator.

Sariel (UIUC) New CS473 19 Fall 2015 19 / 35

slide-66
SLIDE 66

Proof continued

1

Claim: if a wire carry a value ai, when the sorting network get input a1, . . . , an, then for input f(a1), . . . , f(an) this wire would carry the value f(ai).

2

Proof by induction on the depth on the wire at each point.

3

If point has depth 0, then its input and claim trivially hold.

4

Assume holds for all points in circuit of depth ≤ qi, and consider a point p on a wire of depth i + 1.

5

G: gate which this wire is an output of.

6

By induction, claim holds for inputs of G. Now, the claim holds for the gate G itself. Apply above single gate proof for G. = ⇒ claim holds at p.

Sariel (UIUC) New CS473 20 Fall 2015 20 / 35

slide-67
SLIDE 67

Proof continued

1

Claim: if a wire carry a value ai, when the sorting network get input a1, . . . , an, then for input f(a1), . . . , f(an) this wire would carry the value f(ai).

2

Proof by induction on the depth on the wire at each point.

3

If point has depth 0, then its input and claim trivially hold.

4

Assume holds for all points in circuit of depth ≤ qi, and consider a point p on a wire of depth i + 1.

5

G: gate which this wire is an output of.

6

By induction, claim holds for inputs of G. Now, the claim holds for the gate G itself. Apply above single gate proof for G. = ⇒ claim holds at p.

Sariel (UIUC) New CS473 20 Fall 2015 20 / 35

slide-68
SLIDE 68

Proof continued

1

Claim: if a wire carry a value ai, when the sorting network get input a1, . . . , an, then for input f(a1), . . . , f(an) this wire would carry the value f(ai).

2

Proof by induction on the depth on the wire at each point.

3

If point has depth 0, then its input and claim trivially hold.

4

Assume holds for all points in circuit of depth ≤ qi, and consider a point p on a wire of depth i + 1.

5

G: gate which this wire is an output of.

6

By induction, claim holds for inputs of G. Now, the claim holds for the gate G itself. Apply above single gate proof for G. = ⇒ claim holds at p.

Sariel (UIUC) New CS473 20 Fall 2015 20 / 35

slide-69
SLIDE 69

Proof continued

1

Claim: if a wire carry a value ai, when the sorting network get input a1, . . . , an, then for input f(a1), . . . , f(an) this wire would carry the value f(ai).

2

Proof by induction on the depth on the wire at each point.

3

If point has depth 0, then its input and claim trivially hold.

4

Assume holds for all points in circuit of depth ≤ qi, and consider a point p on a wire of depth i + 1.

5

G: gate which this wire is an output of.

6

By induction, claim holds for inputs of G. Now, the claim holds for the gate G itself. Apply above single gate proof for G. = ⇒ claim holds at p.

Sariel (UIUC) New CS473 20 Fall 2015 20 / 35

slide-70
SLIDE 70

Proof continued

1

Claim: if a wire carry a value ai, when the sorting network get input a1, . . . , an, then for input f(a1), . . . , f(an) this wire would carry the value f(ai).

2

Proof by induction on the depth on the wire at each point.

3

If point has depth 0, then its input and claim trivially hold.

4

Assume holds for all points in circuit of depth ≤ qi, and consider a point p on a wire of depth i + 1.

5

G: gate which this wire is an output of.

6

By induction, claim holds for inputs of G. Now, the claim holds for the gate G itself. Apply above single gate proof for G. = ⇒ claim holds at p.

Sariel (UIUC) New CS473 20 Fall 2015 20 / 35

slide-71
SLIDE 71

24.3.1.1:Sorting correctly binary sequences implies

real sorting

Sariel (UIUC) New CS473 21 Fall 2015 21 / 35

slide-72
SLIDE 72

0/1 sorting implies real sorting

Theorem

If a comparison network with n inputs sorts all 2n binary strings of length n correctly, then it sorts all sequences correctly.

Sariel (UIUC) New CS473 22 Fall 2015 22 / 35

slide-73
SLIDE 73

Proof: 0/1 sorting implies real sorting

1

Assume for contradiction that fails for input a1, . . . , an. Let b1, . . . bn be the output sequence for this input.

2

Let ai < ak be the two numbers that are output in incorrect

  • rder (i.e. ak appears before ai in output).

3

f(x) =

  • x ≤ ai

1 x > ai.

4

By lemma for input f(a1), . . . , f(an), circuit would output f(b1), . . . , f(bn).

5

This sequence looks like: 000..0????f(ak)????f(ai)??1111

6

but f(ai) = 0 and f(aj) = 1. Namely, the output is a sequence of the form ????1????0????, which is not sorted.

7

  • bin. input f(b1), . . . , f(bn) sorting net’ fails. A

contradiction.

Sariel (UIUC) New CS473 23 Fall 2015 23 / 35

slide-74
SLIDE 74

Proof: 0/1 sorting implies real sorting

1

Assume for contradiction that fails for input a1, . . . , an. Let b1, . . . bn be the output sequence for this input.

2

Let ai < ak be the two numbers that are output in incorrect

  • rder (i.e. ak appears before ai in output).

3

f(x) =

  • x ≤ ai

1 x > ai.

4

By lemma for input f(a1), . . . , f(an), circuit would output f(b1), . . . , f(bn).

5

This sequence looks like: 000..0????f(ak)????f(ai)??1111

6

but f(ai) = 0 and f(aj) = 1. Namely, the output is a sequence of the form ????1????0????, which is not sorted.

7

  • bin. input f(b1), . . . , f(bn) sorting net’ fails. A

contradiction.

Sariel (UIUC) New CS473 23 Fall 2015 23 / 35

slide-75
SLIDE 75

Proof: 0/1 sorting implies real sorting

1

Assume for contradiction that fails for input a1, . . . , an. Let b1, . . . bn be the output sequence for this input.

2

Let ai < ak be the two numbers that are output in incorrect

  • rder (i.e. ak appears before ai in output).

3

f(x) =

  • x ≤ ai

1 x > ai.

4

By lemma for input f(a1), . . . , f(an), circuit would output f(b1), . . . , f(bn).

5

This sequence looks like: 000..0????f(ak)????f(ai)??1111

6

but f(ai) = 0 and f(aj) = 1. Namely, the output is a sequence of the form ????1????0????, which is not sorted.

7

  • bin. input f(b1), . . . , f(bn) sorting net’ fails. A

contradiction.

Sariel (UIUC) New CS473 23 Fall 2015 23 / 35

slide-76
SLIDE 76

Proof: 0/1 sorting implies real sorting

1

Assume for contradiction that fails for input a1, . . . , an. Let b1, . . . bn be the output sequence for this input.

2

Let ai < ak be the two numbers that are output in incorrect

  • rder (i.e. ak appears before ai in output).

3

f(x) =

  • x ≤ ai

1 x > ai.

4

By lemma for input f(a1), . . . , f(an), circuit would output f(b1), . . . , f(bn).

5

This sequence looks like: 000..0????f(ak)????f(ai)??1111

6

but f(ai) = 0 and f(aj) = 1. Namely, the output is a sequence of the form ????1????0????, which is not sorted.

7

  • bin. input f(b1), . . . , f(bn) sorting net’ fails. A

contradiction.

Sariel (UIUC) New CS473 23 Fall 2015 23 / 35

slide-77
SLIDE 77

Proof: 0/1 sorting implies real sorting

1

Assume for contradiction that fails for input a1, . . . , an. Let b1, . . . bn be the output sequence for this input.

2

Let ai < ak be the two numbers that are output in incorrect

  • rder (i.e. ak appears before ai in output).

3

f(x) =

  • x ≤ ai

1 x > ai.

4

By lemma for input f(a1), . . . , f(an), circuit would output f(b1), . . . , f(bn).

5

This sequence looks like: 000..0????f(ak)????f(ai)??1111

6

but f(ai) = 0 and f(aj) = 1. Namely, the output is a sequence of the form ????1????0????, which is not sorted.

7

  • bin. input f(b1), . . . , f(bn) sorting net’ fails. A

contradiction.

Sariel (UIUC) New CS473 23 Fall 2015 23 / 35

slide-78
SLIDE 78

Proof: 0/1 sorting implies real sorting

1

Assume for contradiction that fails for input a1, . . . , an. Let b1, . . . bn be the output sequence for this input.

2

Let ai < ak be the two numbers that are output in incorrect

  • rder (i.e. ak appears before ai in output).

3

f(x) =

  • x ≤ ai

1 x > ai.

4

By lemma for input f(a1), . . . , f(an), circuit would output f(b1), . . . , f(bn).

5

This sequence looks like: 000..0????f(ak)????f(ai)??1111

6

but f(ai) = 0 and f(aj) = 1. Namely, the output is a sequence of the form ????1????0????, which is not sorted.

7

  • bin. input f(b1), . . . , f(bn) sorting net’ fails. A

contradiction.

Sariel (UIUC) New CS473 23 Fall 2015 23 / 35

slide-79
SLIDE 79

Proof: 0/1 sorting implies real sorting

1

Assume for contradiction that fails for input a1, . . . , an. Let b1, . . . bn be the output sequence for this input.

2

Let ai < ak be the two numbers that are output in incorrect

  • rder (i.e. ak appears before ai in output).

3

f(x) =

  • x ≤ ai

1 x > ai.

4

By lemma for input f(a1), . . . , f(an), circuit would output f(b1), . . . , f(bn).

5

This sequence looks like: 000..0????f(ak)????f(ai)??1111

6

but f(ai) = 0 and f(aj) = 1. Namely, the output is a sequence of the form ????1????0????, which is not sorted.

7

  • bin. input f(b1), . . . , f(bn) sorting net’ fails. A

contradiction.

Sariel (UIUC) New CS473 23 Fall 2015 23 / 35

slide-80
SLIDE 80

Proof: 0/1 sorting implies real sorting

1

Assume for contradiction that fails for input a1, . . . , an. Let b1, . . . bn be the output sequence for this input.

2

Let ai < ak be the two numbers that are output in incorrect

  • rder (i.e. ak appears before ai in output).

3

f(x) =

  • x ≤ ai

1 x > ai.

4

By lemma for input f(a1), . . . , f(an), circuit would output f(b1), . . . , f(bn).

5

This sequence looks like: 000..0????f(ak)????f(ai)??1111

6

but f(ai) = 0 and f(aj) = 1. Namely, the output is a sequence of the form ????1????0????, which is not sorted.

7

  • bin. input f(b1), . . . , f(bn) sorting net’ fails. A

contradiction.

Sariel (UIUC) New CS473 23 Fall 2015 23 / 35

slide-81
SLIDE 81

24.4: A bitonic sorting network

Sariel (UIUC) New CS473 24 Fall 2015 24 / 35

slide-82
SLIDE 82

Bitonic sorting network

Definition

A bitonic sequence is a sequence which is first increasing and then decreasing, or can be circularly shifted to become so.

example

The sequences (1, 2, 3, π, 4, 5, 4, 3, 2, 1) and (4, 5, 4, 3, 2, 1, 1, 2, 3) are bitonic, while the sequence (1, 2, 1, 2) is not bitonic.

Sariel (UIUC) New CS473 25 Fall 2015 25 / 35

slide-83
SLIDE 83

Bitonic sorting network

Definition

A bitonic sequence is a sequence which is first increasing and then decreasing, or can be circularly shifted to become so.

example

The sequences (1, 2, 3, π, 4, 5, 4, 3, 2, 1) and (4, 5, 4, 3, 2, 1, 1, 2, 3) are bitonic, while the sequence (1, 2, 1, 2) is not bitonic.

Sariel (UIUC) New CS473 25 Fall 2015 25 / 35

slide-84
SLIDE 84

Binary bitonic sequences

Observation

binary bitonic sequence is either of the form 0i1j0k or of the form 1i0j1k, where 0i (resp, 1i) denote a sequence of i zeros (resp.,

  • nes).

Sariel (UIUC) New CS473 26 Fall 2015 26 / 35

slide-85
SLIDE 85

Bitonic sorting network

Definition

A bitonic sorter is a comparison network that sorts all bitonic sequences correctly.

Sariel (UIUC) New CS473 27 Fall 2015 27 / 35

slide-86
SLIDE 86

Half cleaner...

Definition

half-cleaner: a comparison network, connecting line i with line i + n/2.

Sariel (UIUC) New CS473 28 Fall 2015 28 / 35

slide-87
SLIDE 87

Half cleaner...

Definition

half-cleaner: a comparison network, connecting line i with line i + n/2.

Sariel (UIUC) New CS473 28 Fall 2015 28 / 35

slide-88
SLIDE 88

Half cleaner...

Definition

half-cleaner: a comparison network, connecting line i with line i + n/2. Half-Cleaner[n] denote half-cleaner with n inputs.

Sariel (UIUC) New CS473 28 Fall 2015 28 / 35

slide-89
SLIDE 89

Half cleaner...

Definition

half-cleaner: a comparison network, connecting line i with line i + n/2. Half-Cleaner[n] denote half-cleaner with n inputs. Depth of Half-Cleaner[n] is one.

Sariel (UIUC) New CS473 28 Fall 2015 28 / 35

slide-90
SLIDE 90

Half cleaner on bitonic sequence...

111..111 000..000 000..000 000..000 111..111 111..111 111 000..000 000..000 111..111 111 000..000 000..000 111 000..000 half− cleaner 1

What a half-cleaner do to an input which is a (binary) bitonic sequence?

2

In example... left half size is clean and all equal to 0.

3

Right side of the output is bitonic.

4

Specifically, one can prove by simple (but tedious) case analysis that the following lemma holds.

Sariel (UIUC) New CS473 29 Fall 2015 29 / 35

slide-91
SLIDE 91

Half cleaner on bitonic sequence...

111..111 000..000 000..000 000..000 111..111 111..111 111 000..000 000..000 111..111 111 000..000 000..000 111 000..000 half− cleaner 1

What a half-cleaner do to an input which is a (binary) bitonic sequence?

2

In example... left half size is clean and all equal to 0.

3

Right side of the output is bitonic.

4

Specifically, one can prove by simple (but tedious) case analysis that the following lemma holds.

Sariel (UIUC) New CS473 29 Fall 2015 29 / 35

slide-92
SLIDE 92

Half cleaner on bitonic sequence...

111..111 000..000 000..000 000..000 111..111 111..111 111 000..000 000..000 111..111 111 000..000 000..000 111 000..000 half− cleaner 1

What a half-cleaner do to an input which is a (binary) bitonic sequence?

2

In example... left half size is clean and all equal to 0.

3

Right side of the output is bitonic.

4

Specifically, one can prove by simple (but tedious) case analysis that the following lemma holds.

Sariel (UIUC) New CS473 29 Fall 2015 29 / 35

slide-93
SLIDE 93

Half cleaner on bitonic sequence...

111..111 000..000 000..000 000..000 111..111 111..111 111 000..000 000..000 111..111 111 000..000 000..000 111 000..000 half− cleaner 1

What a half-cleaner do to an input which is a (binary) bitonic sequence?

2

In example... left half size is clean and all equal to 0.

3

Right side of the output is bitonic.

4

Specifically, one can prove by simple (but tedious) case analysis that the following lemma holds.

Sariel (UIUC) New CS473 29 Fall 2015 29 / 35

slide-94
SLIDE 94

Half cleaner half sorts a bitonic sequence...

Lemma

If the input to a half-cleaner (of size n) is a binary bitonic sequence then for the output sequence we have that (i) the elements in the top half are smaller than the elements in bottom half, and (ii) one of the halves is clean, and the other is bitonic.

Sariel (UIUC) New CS473 30 Fall 2015 30 / 35

slide-95
SLIDE 95

Proof

Proof.

If the sequence is of the form 0i1j0k and the block of ones is completely on the left side (i.e., its part of the first n/2 bits) or the right side, the claim trivially holds. So, assume that the block of ones starts at position n/2 − β and ends at n/2 + α.

00 . . . 00 111 . . . 111 000 . . . 000 11 . . . 11 HalfCleaner 00 . . . 00 00 . . . 00 11 111 . . . 111

α

  • β

If n/2 − α ≥ β then this is exactly the case depicted above and claim holds. If n/2 − α < β then the second half is going to be all

  • nes, as depicted on the right. Implying the claim for this case.

A similar analysis holds if the sequence is of the form 1i0j1k.

Sariel (UIUC) New CS473 31 Fall 2015 31 / 35

slide-96
SLIDE 96

Bitonic sorter - sorts bitonic sequences...

✂✁☎✄✝✆✟✞✠✁☛✡ ☞ ✌ ✆✎✍✎✄✝✏✑✍✓✒✕✔ ✖✘✗ ☞ ✡✚✙✛✏✢✜✣✞✤✏✥✍✧✦★✞✪✩ ✫✬✜✭✙✯✮ ☞ ✌ ✆✎✍✎✄✝✏✑✍ ✒✕✔ ✖✘✗ ✂✁☎✄✰✆✎✞✠✁☛✡ ☞ ✌ ✆✎✍✎✄✝✏✥✍✱✦★✞✲✩ ✂✁☎✄✝✆✟✞✠✁☛✡
  • ✁✄✂✆☎✞✝✠✟✡☎☞☛✍✌✎✟✑✏
✒ ✝✓✂✕✔

(i) (ii) (iii) (i) recursive construction of BitonicSorter[n], (ii) opening up the recursive construction, and (iii) the resulting comparison network.

Sariel (UIUC) New CS473 32 Fall 2015 32 / 35

slide-97
SLIDE 97

Bitonic sorter... the result

Lemma

BitonicSorter[n] sorts bitonic sequences of length n = 2k, it uses (n/2)k = (n/2) lg n gates, and it is of depth k = lg n.

Sariel (UIUC) New CS473 33 Fall 2015 33 / 35

slide-98
SLIDE 98

Merging sequence

1

Merging question: Given two sorted sequences of length n/2, how do we merge them into a single sorted sequence?

2

Concatenate the two sequences...

3

... second sequence is being flipped (i.e., reversed).

4

Easy to verify that the resulting sequence is bitonic, and as such we can sort it using the BitonicSorter[n].

5

Given two sorted sequences a1 ≤ a2 ≤ . . . ≤ an and b1 ≤ b2 ≤ . . . ≤ bn, observe that the sequence a1, a2, . . . , an, bn, bn−1, bn−2, . . . , b2, b1 is bitonic.

Sariel (UIUC) New CS473 34 Fall 2015 34 / 35

slide-99
SLIDE 99

Merger[n]: Using a bitonic sorter

Merging two sorted sequences into a sorted sequence

✂✁☎✄✝✆✟✞✠✁☛✡ ☞ ✌ ✆✎✍✏✄✝✑✒✍✔✓✕✞✗✖ ✘ ✑✒✍✎✙✚✑✒✍✛✓✜✞✗✖

(i) (ii) (iii) (iv) (i) Merger via flipping the lines of bitonic sorter. (ii) BitonicSorter. (iii) Merger after we “physically” flip the lines. (iv) Equivalent drawing of the resulting Merger.

Sariel (UIUC) New CS473 35 Fall 2015 35 / 35

slide-100
SLIDE 100

Merger[n] described using FlipCleaner

  • ✁✄✂✆☎✞✝✠✟✡☎☞☛✍✌✎✟✑✏
✒ ✂✔✓✖✕ ✗ ✓✙✘✛✚✜✟✢✓✣✁
✚✥☛✥✘✛☎✦☛★✧✪✩ ✫✭✬
✚✥☛✥✘✛☎✦☛ ✧✪✩ ✫✭✬ ✗ ✓✙✘✛✚✜✟✢✓✣✁

(i) (ii) (i) FlipCleaner[n], and (ii) Merger[n] described using FlipCleaner.

Sariel (UIUC) New CS473 36 Fall 2015 36 / 35

slide-101
SLIDE 101

What Merger[n] does...

Lemma

The circuit Merger[n] gets as input two sorted sequences of length n/2 = 2k−1, it uses (n/2)k = (n/2) lg n gates, and it is of depth k = lg n, and it outputs a sorted sequence.

Sariel (UIUC) New CS473 37 Fall 2015 37 / 35

slide-102
SLIDE 102

24.5: Sorting Network

Sariel (UIUC) New CS473 38 Fall 2015 38 / 35

slide-103
SLIDE 103

Sorting Network

Finally...

Implement merge sort using Merger[n]. Sorter[n]:

  • ✁✄✂✆☎✝✁✄✂✟✞✡✠☞☛
✌✎✍✏✂✒✑✓✁✄✂✕✔✗✖ ✘✒✙ ✌✎✍✏✂✒✑✓✁✄✂ ✔✗✖ ✘✒✙

Lemma

The circuit Sorter[n] is a sorting network (i.e., it sorts any n numbers) using G(n) = O(n log2 n) gates. It has depth O(log2 n). Namely, Sorter[n] sorts n numbers in O(log2 n) time.

Sariel (UIUC) New CS473 39 Fall 2015 39 / 35

slide-104
SLIDE 104

Proof

Proof.

The number of gates is G(n) = 2G(n/2) + Gates(Merger[n]). Which is G(n) = 2G(n/2) + O(n log n) = O(n log2 n). As for the depth, we have that D(n) = D(n/2)+Depth(Merger[n]) = D(n/2)+O(log(n)), and thus D(n) = O(log2 n), as claimed.

Sariel (UIUC) New CS473 40 Fall 2015 40 / 35

slide-105
SLIDE 105

Resulting sorted

Figure: Sorter[8].

Sariel (UIUC) New CS473 41 Fall 2015 41 / 35

slide-106
SLIDE 106

24.6: Faster sorting networks

Sariel (UIUC) New CS473 42 Fall 2015 42 / 35

slide-107
SLIDE 107

Faster sorting networks

1

Known: sorting network of logarithmic depth Ajtai et al. [1983].

2

Known as the AKS sorting network.

3

Construction is complicated.

4

Ajtai et al. [1983] is better than bitonic sort for n larger than 28046.

Sariel (UIUC) New CS473 43 Fall 2015 43 / 35

slide-108
SLIDE 108

Notes

Sariel (UIUC) New CS473 44 Fall 2015 44 / 35

slide-109
SLIDE 109

Notes

Sariel (UIUC) New CS473 45 Fall 2015 45 / 35

slide-110
SLIDE 110

Notes

Sariel (UIUC) New CS473 46 Fall 2015 46 / 35

slide-111
SLIDE 111

Notes

Sariel (UIUC) New CS473 47 Fall 2015 47 / 35

slide-112
SLIDE 112
  • M. Ajtai, J. Koml´
  • s, and E. Szemer´
  • edi. An O(n log n) sorting
  • network. In Proc. 15th Annu. ACM Sympos. Theory Comput.

(STOC), pages 1–9, 1983.

Sariel (UIUC) New CS473 47 Fall 2015 47 / 35