by Cristian Chilipirea
9 6 9 4 2 7 6 5 6 1
Bubble sort
6 9 9 4 2 7 6 5 6 1
6 9 9 4 2 7 6 5 6 1
6 9 4 9 2 7 6 5 6 1
6 9 4 2 9 7 6 5 6 1
by Cristian Chilipirea
6 9 4 2 7 9 6 5 6 1
Bubble sort
6 9 4 2 7 6 9 5 6 1
6 9 4 2 7 6 5 9 6 1
6 9 4 2 7 6 5 6 9 1
6 9 4 2 7 6 5 6 1 9
Repeat
until
sorted
by Cristian Chilipirea
6 9 4 2 7 6 5 6 1 9
Bubble sort
6 4 9 2 7 6 5 6 1 9
6 4 2 9 7 6 5 6 1 9
6 4 2 7 9 6 5 6 1 9
6 4 2 7 6 9 5 6 1 9
by Cristian Chilipirea
6 4 2 7 6 5 9 6 1 9
Bubble sort
6 4 2 7 6 5 6 9 1 9
6 4 2 7 6 5 6 1 9 9
6 4 2 7 6 5 6 1 9 9
……….
Complexity: O(𝒏 𝟐
)
It goes through all elements
Guaranteed to sort in n repetitions
Named bubble because large elements raise to the surface
(similar to bubbles in sparkling water)
by Cristian Chilipirea
Bubble sort
1 2 4 5 6 6 6 7 9 9
……….
4 6 2 7 6 5 6 1 9 9
by Cristian Chilipirea
9 6 9 4 2 7 6 5 6 1
Parallel bubble sort
6 9 9 4 2 7 6 5 6 1
These two operations (and all pairs like them)
cannot be executed in parallel
by Cristian Chilipirea
9 6 9 4 2 7 6 5 6 1
Parallel bubble sort
6 9 9 4 2 7 6 5 6 1
These two operations (and all pairs like them)
cannot be executed in parallel
Solution hint: The operations do not need
to be executed in exactly the same order
by Cristian Chilipirea
9 6 9 4 2 7 6 5 6 1
OETS: Odd-Even Transposition Sort
9 6 9 4 2 7 6 5 6 1
Repeat until
sorted
(maximum n
times
guarantee)
by Cristian Chilipirea
9 6 9 4 2 7 6 5 6 1
OETS: Odd-Even Transposition Sort
9 6 9 4 2 7 6 5 6 1
………..
………..
Can be
executed
in parallel
Can be
executed
in parallel
………..
by Cristian Chilipirea
9 6 9 4 2 7 6 5 6 1
OETS: Odd-Even Transposition Sort
9 6 9 4 2 7 6 5 6 1
………..
………..
………..
Can NOT be
executed
in parallel
by Cristian Chilipirea
9 6 9 4 2 7 6 5 6 1
OETS: Odd-Even Transposition Sort
9 6 9 4 2 7 6 5 6 1
………..
………..
………..
Solution:
Barrier
between
each
iteration
by Cristian Chilipirea
9 6 9 4 2 7 6 5 6 1
OETS: Odd-Even Transposition Sort
9 6 9 4 2 7 6 5 6 1
………..
………..
………..
Parallel complexity:
p = threads or
processor cores
O(
𝑛
𝑝
∗ 𝑛) = O(𝑛) for p=n
by Cristian Chilipirea
9 6 9 4 2 7 6 5 6 1
OETS: Odd-Even Transposition Sort
6 9 4 9 2 7 5 6 1 6
6 4 9 2 9 5 7 1 6 6
4 6 2 9 5 9 1 7 6 6
by Cristian Chilipirea
OETS: Odd-Even Transposition Sort
4 2 6 5 9 1 9 6 7 6
2 4 5 6 1 9 6 9 6 7
2 4 5 1 6 6 9 6 9 7
2 4 1 5 6 6 6 9 7 9
by Cristian Chilipirea
OETS: Odd-Even Transposition Sort
2 1 4 5 6 6 6 7 9 9
1 2 4 5 6 6 6 7 9 9
1 2 4 5 6 6 6 7 9 9
1 2 4 5 6 6 6 7 9 9

Oets parallel bubble sort

  • 1.
    by Cristian Chilipirea 96 9 4 2 7 6 5 6 1 Bubble sort 6 9 9 4 2 7 6 5 6 1 6 9 9 4 2 7 6 5 6 1 6 9 4 9 2 7 6 5 6 1 6 9 4 2 9 7 6 5 6 1
  • 2.
    by Cristian Chilipirea 69 4 2 7 9 6 5 6 1 Bubble sort 6 9 4 2 7 6 9 5 6 1 6 9 4 2 7 6 5 9 6 1 6 9 4 2 7 6 5 6 9 1 6 9 4 2 7 6 5 6 1 9 Repeat until sorted
  • 3.
    by Cristian Chilipirea 69 4 2 7 6 5 6 1 9 Bubble sort 6 4 9 2 7 6 5 6 1 9 6 4 2 9 7 6 5 6 1 9 6 4 2 7 9 6 5 6 1 9 6 4 2 7 6 9 5 6 1 9
  • 4.
    by Cristian Chilipirea 64 2 7 6 5 9 6 1 9 Bubble sort 6 4 2 7 6 5 6 9 1 9 6 4 2 7 6 5 6 1 9 9 6 4 2 7 6 5 6 1 9 9 ……….
  • 5.
    Complexity: O(𝒏 𝟐 ) Itgoes through all elements Guaranteed to sort in n repetitions Named bubble because large elements raise to the surface (similar to bubbles in sparkling water) by Cristian Chilipirea Bubble sort 1 2 4 5 6 6 6 7 9 9 ………. 4 6 2 7 6 5 6 1 9 9
  • 6.
    by Cristian Chilipirea 96 9 4 2 7 6 5 6 1 Parallel bubble sort 6 9 9 4 2 7 6 5 6 1 These two operations (and all pairs like them) cannot be executed in parallel
  • 7.
    by Cristian Chilipirea 96 9 4 2 7 6 5 6 1 Parallel bubble sort 6 9 9 4 2 7 6 5 6 1 These two operations (and all pairs like them) cannot be executed in parallel Solution hint: The operations do not need to be executed in exactly the same order
  • 8.
    by Cristian Chilipirea 96 9 4 2 7 6 5 6 1 OETS: Odd-Even Transposition Sort 9 6 9 4 2 7 6 5 6 1 Repeat until sorted (maximum n times guarantee)
  • 9.
    by Cristian Chilipirea 96 9 4 2 7 6 5 6 1 OETS: Odd-Even Transposition Sort 9 6 9 4 2 7 6 5 6 1 ……….. ……….. Can be executed in parallel Can be executed in parallel ………..
  • 10.
    by Cristian Chilipirea 96 9 4 2 7 6 5 6 1 OETS: Odd-Even Transposition Sort 9 6 9 4 2 7 6 5 6 1 ……….. ……….. ……….. Can NOT be executed in parallel
  • 11.
    by Cristian Chilipirea 96 9 4 2 7 6 5 6 1 OETS: Odd-Even Transposition Sort 9 6 9 4 2 7 6 5 6 1 ……….. ……….. ……….. Solution: Barrier between each iteration
  • 12.
    by Cristian Chilipirea 96 9 4 2 7 6 5 6 1 OETS: Odd-Even Transposition Sort 9 6 9 4 2 7 6 5 6 1 ……….. ……….. ……….. Parallel complexity: p = threads or processor cores O( 𝑛 𝑝 ∗ 𝑛) = O(𝑛) for p=n
  • 13.
    by Cristian Chilipirea 96 9 4 2 7 6 5 6 1 OETS: Odd-Even Transposition Sort 6 9 4 9 2 7 5 6 1 6 6 4 9 2 9 5 7 1 6 6 4 6 2 9 5 9 1 7 6 6
  • 14.
    by Cristian Chilipirea OETS:Odd-Even Transposition Sort 4 2 6 5 9 1 9 6 7 6 2 4 5 6 1 9 6 9 6 7 2 4 5 1 6 6 9 6 9 7 2 4 1 5 6 6 6 9 7 9
  • 15.
    by Cristian Chilipirea OETS:Odd-Even Transposition Sort 2 1 4 5 6 6 6 7 9 9 1 2 4 5 6 6 6 7 9 9 1 2 4 5 6 6 6 7 9 9 1 2 4 5 6 6 6 7 9 9